Jump to content

lengthen delta multiple


Recommended Posts

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.

Link to comment
Share on other sites

Guest Alan Cullen

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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'~

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 1 year later...

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.

Link to comment
Share on other sites

  • 5 years later...

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 by SLW210
Changed Quote Tags to Code Tags!
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...