LukeCAD Posted February 17, 2008 Share Posted February 17, 2008 hi guys, im sure this must be easy but i cant work it out, i need to extend multiple lines by a given length, but using _lengthen;delta can only do one at a time - time consuming. How can i do lots of lines at once? (i need to extend them all the same direction) Thanks in advance Luke. Quote Link to comment Share on other sites More sharing options...
Guest Alan Cullen Posted February 17, 2008 Share Posted February 17, 2008 I would suggest conning someone like ASMI into writing a lisp/VBA for you. If you have no luck with it, it is a challenge, and I may look at it for you tomorrow night. ASMI is on line at the moment, but he only looks at Autolisp, VBA and Customisation, so I suggest you rapidly post there. Tell anyone I sent you there, in case they have a go at you for double posting. Quote Link to comment Share on other sites More sharing options...
LukeCAD Posted February 17, 2008 Author Share Posted February 17, 2008 thanks Alan, i have posted there, fingers crossed, if not, sounds like you like a challenge ) Quote Link to comment Share on other sites More sharing options...
ASMI Posted February 17, 2008 Share Posted February 17, 2008 Something like this? (defun c:blen(/ lSet actDoc lDel doMode objLst) (vl-load-com) (princ "\n>>> Select lines to extend/reduce <<< ") (if (and (setq lSet (ssget '((0 . "LINE")))); (setq lDel (getreal "\nSpecify delta: ")) ); end and (progn (initget 1 "Positive Negative Both") (setq doMode (getkword "\nSpecify direction [Positive/Negative/Both]: ") objLst(mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr(ssnamex lSet))))); end setq (vla-StartUndoMark (setq actDoc (vla-get-ActiveDocument (vlax-get-acad-object)))); end vla-StartUndoMark (if(member doMode '("Negative" "Both")) (foreach ln objLst (vlax-put ln 'startpoint (polar (vlax-get ln 'startpoint) (vlax-get ln 'angle)(- lDel))); end vlax-put ); end foreach ); end if (if(member doMode '("Positive" "Both")) (foreach ln objLst (vlax-put ln 'endpoint (polar (vlax-get ln 'endpoint) (vlax-get ln 'angle)lDel)) ); end foreach ); end if (vla-EndUndoMark actDoc) ); end progn ); end if (princ) ); end of c:blen Quote Link to comment Share on other sites More sharing options...
Guest Alan Cullen Posted February 17, 2008 Share Posted February 17, 2008 yeah, yeah, yeah. Looks like I dobbed myself in again. My fingers are also crossed (I really don't want to do it). Quote Link to comment Share on other sites More sharing options...
LukeCAD Posted February 17, 2008 Author Share Posted February 17, 2008 something like that would be excellent, but, sorry, i forgot to mention my lines are all polylines. Quote Link to comment Share on other sites More sharing options...
Guest Alan Cullen Posted February 17, 2008 Share Posted February 17, 2008 God, ASMI is so fast, that's why he is a guru. Quote Link to comment Share on other sites More sharing options...
fixo Posted February 17, 2008 Share Posted February 17, 2008 No commands but it works (defun C:LG() (if (setq ss (ssget '((0 . "line")))) (progn (alert " Specify two points of an imagined line\n aside which will extend the selected lines") (setq p1 (getpoint "\nPick the first point of virtual fence line: ") p2 (getpoint p1 "\nPick the second point: ") ) (setq delta (getreal "\nEnter delta: ")) (while (setq en (ssname ss 0)) (setq elist (entget en) sp (cdr (assoc 10 elist)) ep (cdr (assoc 11 elist)) dis (distance sp ep) leng (* delta dis) ip (inters sp ep p1 p2 nil) ) (if (< (distance sp ip)(distance ep ip)) (progn (setq dp sp)(setq dir T)) (progn (setq dp ep)(setq dir nil)) ) (setq ang (angle dp ip)) (setq np (polar dp ang leng)) (entmod (subst (if dir (cons 10 np)(cons 11 np)) (if dir (assoc 10 elist)(assoc 11 elist)) elist) ) (entupd en) (ssdel en ss) ) ) ) ) ~'J'~ Quote Link to comment Share on other sites More sharing options...
ASMI Posted February 17, 2008 Share Posted February 17, 2008 something like that would be excellent, but, sorry, i forgot to mention my lines are all polylines. For LWPolylines: (defun c:plen(/ plSet plDel plLst doMode dxfLst newEn newSt newPl) (princ "\n <<< SELECT POLYLINES >>>") (if (and (setq plSet(ssget '((0 . "LWPOLYLINE")))) (setq plDel(getreal "\nSpecify delta: ")) ); ena and (progn (setq plLst(vl-remove-if 'listp (mapcar 'cadr(ssnamex plSet)))) (initget 1 "Positive Negative Both") (if(setq doMode (getkword "\nSpecify direction [Positive/Negative/Both]: ")) (progn (foreach pl plLst (setq dxfLst(entget pl) verLst(mapcar 'cdr(vl-remove-if-not '(lambda(x)(= 10(car x)))dxfLst)) newEn(polar(cadr(reverse verLst)) (angle(cadr(reverse verLst))(car(reverse verLst))) (+(distance(cadr(reverse verLst))(car(reverse verLst)))plDel)) newSt(polar(cadr verLst) (angle(cadr verLst)(car verLst)) (+(distance(cadr verLst)(car verLst))plDel)) ); end setq (cond ((= "Positive" doMode) (setq newPl(reverse (subst(cons 10 newEn) (assoc 10(reverse dxfLst))(reverse dxfLst)))) ); end conditon #1 ((= "Negative" doMode) (setq newPl(subst(cons 10 newSt) (assoc 10 dxfLst)dxfLst)) ); end condition #2 ((= "Both" doMode) (setq dxfLst(subst(cons 10 newSt) (assoc 10 dxfLst)dxfLst) newPl(reverse (subst(cons 10 newEn) (assoc 10(reverse dxfLst))(reverse dxfLst)))) ); end condition #3 ); end cond (entmod newPl) ); end foreach ); end progn ); end if ); end progn ); end if (princ) ); end of c:plen Quote Link to comment Share on other sites More sharing options...
LukeCAD Posted February 18, 2008 Author Share Posted February 18, 2008 that is truely fantastic, thankyou. Quote Link to comment Share on other sites More sharing options...
LukeCAD Posted February 18, 2008 Author Share Posted February 18, 2008 and thankyou, alan for pointing my the right way and Fatty for your lisp. Quote Link to comment Share on other sites More sharing options...
bobcat88 Posted October 7, 2009 Share Posted October 7, 2009 Possible to apply the lengthen/shorten to the end of the pline closest to where you seleced the pline? Problem I have is that it is adding length to the opposite end of the pline not shortening the end I picked. Quote Link to comment Share on other sites More sharing options...
iblue Posted August 2, 2015 Share Posted August 2, 2015 (edited) Thanks ASMI for writing a Lengthen Delta Multiple Polyline lisp. this is exactly what I looking for. it's work very good for polyline from autocad. but I try to select the polylines nest file below it doen't work. Anyone can help me please! (defun c:plen(/ plSet plDel plLst doMode dxfLst newEn newSt newPl) (princ "\n <<< SELECT POLYLINES >>>") (if (and (setq plSet(ssget '((0 . "LWPOLYLINE")))) (setq plDel(getreal "\nSpecify delta: ")) ); ena and (progn (setq plLst(vl-remove-if 'listp (mapcar 'cadr(ssnamex plSet)))) (initget 1 "Positive Negative Both") (if(setq doMode (getkword "\nSpecify direction [Positive/Negative/Both]: ")) (progn (foreach pl plLst (setq dxfLst(entget pl) verLst(mapcar 'cdr(vl-remove-if-not '(lambda(x)(= 10(car x)))dxfLst)) newEn(polar(cadr(reverse verLst)) (angle(cadr(reverse verLst))(car(reverse verLst))) (+(distance(cadr(reverse verLst))(car(reverse verLst)))plDel)) newSt(polar(cadr verLst) (angle(cadr verLst)(car verLst)) (+(distance(cadr verLst)(car verLst))plDel)) ); end setq (cond ((= "Positive" doMode) (setq newPl(reverse (subst(cons 10 newEn) (assoc 10(reverse dxfLst))(reverse dxfLst)))) ); end conditon #1 ((= "Negative" doMode) (setq newPl(subst(cons 10 newSt) (assoc 10 dxfLst)dxfLst)) ); end condition #2 ((= "Both" doMode) (setq dxfLst(subst(cons 10 newSt) (assoc 10 dxfLst)dxfLst) newPl(reverse (subst(cons 10 newEn) (assoc 10(reverse dxfLst))(reverse dxfLst)))) ); end condition #3 ); end cond (entmod newPl) ); end foreach ); end progn ); end if ); end progn ); end if (princ) ); end of c:plen LengthenV1.dwg Edited August 3, 2015 by SLW210 Changed Quote Tags to Code Tags! Quote Link to comment Share on other sites More sharing options...
SLW210 Posted August 3, 2015 Share Posted August 3, 2015 Please read Code Posting Guidelines and use Code Tags # next time instead of Quote Tags. I fixed your post for you this time. Quote Link to comment Share on other sites More sharing options...
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.