Posted by: lee7598 Date: Jun/02/04 - 06:42 (EDT) I am trying to change the length of multiple lines. For example, I would like to window over 1000 individual line segments and change the length from 5' to 10'. Is this possible? Right now I am going through the individual lines and scaling them up one at a time. Very time consuming. Any suggestions would be appreciated. -------------------------------------------------------------------------------- Reply From: Tracy W. Lincoln Date: Jun/02/04 - 06:50 (EDT) Re: Editing Multiple Line Lengths Try using the LENGTHEN command and it's TOTAL option. The commmand alias is LEN -- Tracy W. Lincoln Autodesk Discussion Group Facilitator http://www.autodesk.com/discussion-announcements like to window over 1000 individual line segments and change the length from 5' to 10'. Is this possible? Right now I am going through the individual lines and scaling them up one at a time. Very time consuming. Any suggestions would be appreciated. -------------------------------------------------------------------------------- Reply From: bob.at Date: Jun/02/04 - 06:55 (EDT) Re: Editing Multiple Line Lengths Lee try the command "lengthen" with option "fence" bob.at -------------------------------------------------------------------------------- Reply From: Joe Burke Date: Jun/02/04 - 08:00 (EDT) Re: Editing Multiple Line Lengths Bob, Lengthen total also accepts a selection set. (defun c:LineLen ( / len ss ) (setq len (getdist "\nEnter new line length: ")) (setq ss (ssget (list (cons 0 "LINE")))) (command "lengthen" "total" len ss "") (princ) ) Lee, If you only want to change 5' lines to some length, that would need a bit more code. Joe Burke -------------------------------------------------------------------------------- Reply From: lee7598 Date: Jun/02/04 - 09:37 (EDT) Re: Editing Multiple Line Lengths Joe, The program you wrote is right along the lines of what I am looking for, except I need to lengthen the lines from each individual midpoint, basically adding an equal length to each side of all the lines. Is this possible? -------------------------------------------------------------------------------- Reply From: Joe Burke Date: Jun/02/04 - 09:56 (EDT) Re: Editing Multiple Line Lengths Lee, Yes, it can be done. But I think Anne Brown might want to move this thread to the customization NG before we go further. Joe Burke need to lengthen the lines from each individual midpoint, basically adding an equal length to each side of all the lines. Is this possible?
This adds 2.5 units to either end of any line. (defun c:biggerlines ( / add lines cnt line p10 p11 mid len scale) (setq add 2.5 lines (ssget '((0 . "line"))) cnt 0 ) (repeat (sslength lines) (setq line (entget (ssname lines cnt)) p10 (cdr (assoc 10 line)) p11 (cdr (assoc 11 line)) mid (mapcar '+ p10 (mapcar '* (mapcar '- p11 p10) '(0.5 0.5 0.5))) len (distance p10 p11) scale (/ (+ add len add) len) cnt (1+ cnt) ) (command "scale" (cdr (assoc -1 line)) "" "non" mid scale) ) (princ) )
Joe, thanks for learning something new - i never checked this. But in which direction are the differnt lines streched when selecting via selection set? bob.at
Hi Lee7598 Try this (adds the length on both sides of line): (defun C:SetLineLength ( / AcdUtl CurAng CurEnt CurObj CurSet) (vl-load-com) (if (setq CurSet (ssget '((0 . "LINE")))) (progn (while (setq CurEnt (ssname CurSet 0)) (setq AcdUtl (vla-get-Utility (vla-get-ActiveDocument (vlax-get-acad-object) ) ) CurObj (vlax-ename->vla-object CurEnt) CurAng (vla-get-angle CurObj) ) (vla-put-EndPoint CurObj (vla-PolarPoint AcdUtl (vla-get-EndPoint CurObj) CurAng 2.5 ;required half length ) ) (vla-put-StartPoint CurObj (vla-PolarPoint AcdUtl (vla-get-StartPoint CurObj) (+ CurAng pi) 2.5 ;required half length ) ) (ssdel CurEnt CurSet) ) ) ) (princ) ) Cheers
This is almost exactly what I was looking for. Can you make it so that I can get a prompt for a specified line length?
Bob, I think lengthen modifies the end point given a line. Which isn't what Lee is looking for. Looks like Juerg worked out the kinks. Though I haven't tried it. Joe Burke are the differnt lines streched when selecting via selection set?
Hi lee7598 With this mod's you can also shorten/lengthen lines with different lengths: (defun C:SetLineLength ( / AcdUtl CurAng CurEnt CurObj CurSet TmpLen) (vl-load-com) (if (setq CurSet (ssget '((0 . "LINE")))) (progn (or Gb:Len (setq Gb:Len 10.0)) ;default value (initget 6) (setq TmpLen (getreal (strcat "\nNew Line length <" (rtos Gb:Len) ">: ")) Gb:Len (cond (TmpLen) (Gb:Len)) ) (while (setq CurEnt (ssname CurSet 0)) (setq AcdUtl (vla-get-Utility (vla-get-ActiveDocument (vlax-get-acad-object) ) ) CurObj (vlax-ename->vla-object CurEnt) CurAng (vla-get-angle CurObj) TmpLen (- Gb:Len (vla-get-Length CurObj)) ) (vla-put-EndPoint CurObj (vla-PolarPoint AcdUtl (vla-get-EndPoint CurObj) (if (minusp TmpLen) (+ CurAng pi) CurAng) (/ (abs TmpLen) 2.0) ) ) (vla-put-StartPoint CurObj (vla-PolarPoint AcdUtl (vla-get-StartPoint CurObj) (if (minusp TmpLen) CurAng (+ CurAng pi)) (/ (abs TmpLen) 2.0) ) ) (ssdel CurEnt CurSet) ) ) ) (princ) ) Cheers
And... If you replace the line: (if (setq CurSet (ssget '((0 . "LINE")))) with: (if (setq CurSet (cond ((ssget "I" '((0 . "LINE")))) ((ssget '((0 . "LINE")))))) you can also preselect teh entities by grips... Cheers