samthearcher Posted January 13, 2011 Posted January 13, 2011 Hi all, I'm trying to write a lisp that will have the user draw a pline along a path, then offset the pline 3" to each side, change the layer of the two new lines and erase the original pline. The problem I'm having is in getting the pline to offset. I thought the easiest way to get it to offset to each side would be to get the extmin and extmax, but that doesn't seem to be working. Does anyone have any other suggestions or maybe there's an error in my code? (defun C:heattrace () (setq ext1 (getvar "extmin")) (setq ext2 (getvar "extmax")) (command "pline") (while (> (getvar "CMDACTIVE") 0) (command pause)) (setq entity1 (entget (entlast))) (command "OFFSET" e n 3 entity1 ext1 "") (command "CHANGE" l "" p la "P-HEATTRACE" "") (command "OFFSET" e y 3 entity1 ext2) (command "CHANGE" l "" p la "P-HEATTRACE" "") (command "erase" entity1) (princ) ) Many thanks. Quote
ReMark Posted January 13, 2011 Posted January 13, 2011 Maybe if you looked at some of the previously written lisp routines that provide a similar function the method of doing this would be revealed to you. First check the Similar Threads below. If that doesn't do it for you use the Search option above and the word "offset". Quote
Lee Mac Posted January 13, 2011 Posted January 13, 2011 You could draw the PLine, then use this perhaps: http://lee-mac.com/doubleoffset.html Quote
Lee Mac Posted January 13, 2011 Posted January 13, 2011 Or, consider this code: (defun c:test ( / layer doc eLast ent obj ) (vl-load-com) ;; Example by Lee Mac 2011 - www.lee-mac.com (setq layer "P-HEATTRACE" doc (vla-get-ActiveDocument (vlax-get-acad-object)) ) (if (not (tblsearch "LAYER" layer)) (vla-Add (vla-get-Layers doc) layer)) (setq eLast (entlast)) (command "_.pline") (while (= 1 (logand 1 (getvar 'CMDACTIVE))) (command pause)) (if (and (not (equal eLast (setq ent (entlast)))) (setq obj (vlax-ename->vla-object ent)) (vl-every (function (lambda ( d / l ) (if (not (vl-catch-all-error-p (setq l (vl-catch-all-apply 'vlax-invoke (list obj 'Offset d)) ) ) ) (mapcar '(lambda ( o ) (vla-put-Layer o layer)) l) ) ) ) (list 3.0 -3.0) ) ) (entdel ent) ) (princ) ) Quote
alanjt Posted January 13, 2011 Posted January 13, 2011 http://www.cadtutor.net/forum/showthread.php?52810-Looking-for-a-LISP-routine-Multiple-Polyline-Offset Quote
samthearcher Posted January 13, 2011 Author Posted January 13, 2011 Thanks for the help, guys. Lee Mac, I had run across your doubleoffset when I was searching around before I posted. My problem was that I don't know visual enough to edit it. The test example you posted is exactly what I was trying to accomplish. I guess I need to work on my visual lisp. It looks like it is a little more powerful than autolisp. Thanks again! (still not sure why I couldn't call a variable for the offset direction with autolisp...) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.