Author Topic: multi extend at one time  (Read 10556 times)

0 Members and 1 Guest are viewing this topic.

dussla

  • Bull Frog
  • Posts: 254
multi extend at one time
« on: February 09, 2008, 10:32:19 AM »


hello friends
how are you ?
i need some help again ~
please help me again
if you see my attached file , you can see mutilple line

white line : boundary line

my wanted process
if i select 1  boundary edge   or   many boundary edges ,    i would like to extend lines at one time

is that possible ?

gile

  • Water Moccasin
  • Posts: 2231
  • Marseille, France
Re: multi extend at one time
« Reply #1 on: February 09, 2008, 11:54:16 AM »
Hi,

Here's a way for one boundary.
It's quite more difficult with more boundaries.

Code: [Select]
(defun c:extlines (/ bound int pt)
  (vl-load-com)
  (or *acdoc*
      (setq *acdoc* (vla-get-ActiveDocument (vlax-get-acad-object)))
  )
  (if (and (setq bound (car (entsel "\nSelect the boundary: ")))
   (setq bound (vlax-ename->vla-object bound))
      )
    (if (ssget '((0 . "LINE")))
      (progn
(vla-StartUndoMark *acdoc*)
(vlax-for l (vla-get-ActiveSelectionSet *acdoc*)
  (setq int (vlax-invoke bound 'IntersectWith l acExtendOtherEntity))
  (while int
    (setq pt  (list (car int) (cadr int) (caddr int))
  int (cdddr int)
    )
    (if (< (distance (vlax-get l 'StartPoint) pt)
   (distance (vlax-get l 'EndPoint) pt)
)
      (vlax-put l 'StartPoint pt)
      (vlax-put l 'EndPoint pt)
    )
  )
)
(vla-EndUndoMark *acdoc*)
      )
    )
  )
  (princ)
)
« Last Edit: February 09, 2008, 12:02:37 PM by gile »
Speaking English as a French Frog

dussla

  • Bull Frog
  • Posts: 254
Re: multi extend at one time
« Reply #2 on: February 10, 2008, 08:06:41 PM »
gile  .  always  thank you
really , you are   genius  :-) :-) :-)

Bob Wahr

  • Guest
Re: multi extend at one time
« Reply #3 on: February 10, 2008, 09:04:29 PM »
Why automate a built in function?

EXTEND
select boundary objects
FENCE
put in a fence that crosses the lines that you want to extend

ronjonp

  • Needs a day job
  • Posts: 7027
Re: multi extend at one time
« Reply #4 on: February 11, 2008, 05:39:13 PM »
A little late to the show, but here is my contribution to do multiple boundaries:

Code: [Select]
(defun c:mextend (/ ang c e lines lwp lyr ptlst pts ss)
  (if (setq ss (ssget ":L" '((0 . "LWPOLYLINE,LINE,SPLINE,CIRCLE"))))
    (progn
      (mapcar '(lambda (e)
(if (wcmatch (cdr (assoc 0 (entget e))) "LINE")
   (setq lines (cons e lines))
   (setq lwp (cons e lwp))
)
       )
      (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
      )
      (if (and lwp lines)
(foreach l (mapcar 'vlax-ename->vla-object lines)
  (setq ang   (vla-get-angle l)
lyr   (vla-get-layer l)
ptlst nil
  )
  (foreach pl (mapcar 'vlax-ename->vla-object lwp)
    (setq c nil)
    (if
      (and (vlax-property-available-p pl 'closed) (zerop (vlax-get pl 'closed)) (setq c t))
       (vlax-put pl 'closed -1)
    )
    (if (setq pts (vlax-invoke l 'intersectwith pl acextendthisentity))
      (while pts
(setq ptlst (cons (list (car pts) (cadr pts)) ptlst))
(setq pts (cdddr pts))
      )
    )
    (and c (vlax-put pl 'closed 0))
  )
  (if ptlst
    (progn (setq ptlst (vl-sort ptlst
(function (lambda (d1 d2)
    (if (equal ang 0.0 pi)
      (> (car d1) (car d2))
      (< (cadr d1) (cadr d2))
    )
  )
)
       )
   )
   (while ptlst
     (entmakex
       (list '(0 . "LINE") (cons 8 lyr) (cons 10 (car ptlst)) (cons 11 (cadr ptlst)))
     )
     (setq ptlst (cddr ptlst))
   )
   (vla-delete l)
    )
  )
)
      )
    )
  )
  (princ)
)
« Last Edit: November 29, 2010, 01:22:44 PM by ronjonp »

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

dussla

  • Bull Frog
  • Posts: 254
Re: multi extend at one time
« Reply #5 on: February 11, 2008, 07:41:26 PM »
wow ~~~~~ronjonp

that is perpect also

ronjong  ?   i drawn  circles
but that is failure about circle ~~
can you modify some~
at any way  , really thank you~~~

litss

  • Guest
Re: multi extend at one time
« Reply #6 on: February 12, 2008, 12:47:30 AM »
 :-D

ronjonp, great routine! just the one i want

thx!

it takes all the plines as boundary, and then extends all the lines to the boundary, right? if the rects are made of lines, not plines, can it work?  Well, I don't have autocad at hand, just can't test.

BTW, it's that possible to deal with circles,splines,ect.? :( if not, I have to change them into plines. not easy ha






ronjonp

  • Needs a day job
  • Posts: 7027
Re: multi extend at one time
« Reply #7 on: February 12, 2008, 08:42:26 AM »
I updated the code above to work with circles and splines. I'd imagine if the line rectangles were on a separate layer than the lines that needed to be extended, it could work. Or i could modify it to allow for two selections (one to extend and the objects to extend to).

I'll try and work on that later this morn.

Enjoy :)

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

Joe Burke

  • Guest
Re: multi extend at one time
« Reply #8 on: February 12, 2008, 09:37:04 AM »
ronjonp,

Looks interesting.  :-)

One suggestion. If a boundary object is open and one end of a line points toward the open area, the line should not be deleted as it is now. The line end which points toward the closed area of the boundary should extend to there. The other end should remain fixed.

dussla

  • Bull Frog
  • Posts: 254
Re: multi extend at one time
« Reply #9 on: February 12, 2008, 09:48:36 AM »
ronjonp ~ wow  good   

ronjonp  , can you make  this  routine  as your routine  put to practical use

pls see attached image

ronjonp

  • Needs a day job
  • Posts: 7027
Re: multi extend at one time
« Reply #10 on: February 12, 2008, 10:04:48 AM »
Joe,

I'm not sure I understand what you are saying? The intent of the routine was to have an overall closed boundary with multiple closed boundaries within it that would not be crossed by the extending lines.

Dussla,

I'm not clear on the intent of your last question.

Sorry,

Ron
« Last Edit: February 12, 2008, 05:00:19 PM by ronjonp »

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

Joe Burke

  • Guest
Re: multi extend at one time
« Reply #11 on: February 12, 2008, 10:54:36 AM »
ronjonp,

I think I understand the intent of the code, but at least you need some error checking to ensure line objects are not erased which should not be erased.

litss

  • Guest
Re: multi extend at one time
« Reply #12 on: February 12, 2008, 11:01:44 AM »
Thx, ron!

nice one:) It's very helpful for me.

As to the line-boundary question, either way you mentioned will be ok if there are inside boudaries. We have to give the routine some hints, I guess. But, if there is only one boundary, the outside boundary, could you let the routine recoginze it automatically, no matter the outside boundary is made of lines or circles or splines?  


ronjonp

  • Needs a day job
  • Posts: 7027
Re: multi extend at one time
« Reply #13 on: February 12, 2008, 07:22:22 PM »
Updated code above per Joe's recommendation:

« Last Edit: February 12, 2008, 07:26:39 PM by ronjonp »

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

Joe Burke

  • Guest
Re: multi extend at one time
« Reply #14 on: February 13, 2008, 03:40:04 AM »
Nice

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: multi extend at one time
« Reply #15 on: February 13, 2008, 04:28:28 AM »

Yes, very nice Ron !
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

Joe Burke

  • Guest
Re: multi extend at one time
« Reply #16 on: February 13, 2008, 07:19:28 AM »
Ron,

I guess I should mention this, which you probably already know. I think the fix you applied was to temporarily close an open pline. This may cause a line to be broken at the temporary closing segment which doesn't make sense once the pline is set back to open and the routine ends.

I'll post an example if this isn't clear.

ronjonp

  • Needs a day job
  • Posts: 7027
Re: multi extend at one time
« Reply #17 on: February 13, 2008, 09:28:43 AM »

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

xiaxiang

  • Guest
Re: multi extend at one time
« Reply #18 on: November 11, 2010, 10:31:55 PM »
A little late to the show, but here is my contribution to do multiple boundaries:
Code: [Select]
(defun c:mextend (/ ang c d1 d2 e l lines lwp lyr pl ptlst pts ss)
  )
ronjonp ,Need your help
I've loaded your routine"mextend",But it didn't work.
Is there Any Operational errors?

ronjonp

  • Needs a day job
  • Posts: 7027
Re: multi extend at one time
« Reply #19 on: November 11, 2010, 11:13:40 PM »
A little late to the show, but here is my contribution to do multiple boundaries:
Code: [Select]
(defun c:mextend (/ ang c d1 d2 e l lines lwp lyr pl ptlst pts ss)
  )
ronjonp ,Need your help
I've loaded your routine"mextend",But it didn't work.
Is there Any Operational errors?

xiaxiang,

Download the code again and try it .... I'm not sure why it ever worked in the first place  :oops:

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

xiaxiang

  • Guest
Re: multi extend at one time
« Reply #20 on: November 12, 2010, 12:38:23 AM »
A little late to the show, but here is my contribution to do multiple boundaries:
Code: [Select]
(defun c:mextend (/ ang c d1 d2 e l lines lwp lyr pl ptlst pts ss)
  )
ronjonp ,Need your help
I've loaded your routine"mextend",But it didn't work.
Is there Any Operational errors?
xiaxiang,Download the code again and try it .... I'm not sure why it ever worked in the first place  :oops:
Mr Ninja
I try my best again and again .Anxious,and I can't use your code.woking with 2006,maybe version?

ronjonp

  • Needs a day job
  • Posts: 7027
Re: multi extend at one time
« Reply #21 on: November 12, 2010, 10:13:25 AM »
Are the objects you're trying to extend lines? What errors are you seeing?

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

cmwade77

  • Swamp Rat
  • Posts: 1206
Re: multi extend at one time
« Reply #22 on: November 12, 2010, 11:23:25 AM »
Ron,

I noticed that the results change to layer 0, shouldn't this check to see what layer the lines are drawn on, as well as what color, to match them? Just a thought, but very cool routine.

Edit: Actually, it was the color, if it is hard coded that would change.
« Last Edit: November 12, 2010, 11:49:49 AM by cmwade77 »

ronjonp

  • Needs a day job
  • Posts: 7027
Re: multi extend at one time
« Reply #23 on: November 12, 2010, 11:34:59 AM »
Ron,

I noticed that the results change to layer 0, shouldn't this check to see what layer the lines are drawn on, as well as what color, to match them? Just a thought, but very cool routine.

I can't duplicate your results?

Code: [Select]
(while ptlst
  (entmakex (list '(0 . "LINE")
  (cons 8 lyr)
  (cons 10 (car ptlst))
  (cons 11 (cadr ptlst))
    )
  )
  (setq ptlst (cddr ptlst))
)

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

ronjonp

  • Needs a day job
  • Posts: 7027
Re: multi extend at one time
« Reply #24 on: November 18, 2010, 11:33:07 AM »
cmwade77,

Did you get the layer issue sorted out?

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

cmwade77

  • Swamp Rat
  • Posts: 1206
Re: multi extend at one time
« Reply #25 on: November 18, 2010, 12:55:41 PM »
Yes, it turned out the layer wasn't changing, but the color (hard coded was).

xiaxiang

  • Guest
Re: multi extend at one time
« Reply #26 on: November 25, 2010, 08:07:21 AM »
Are the objects you're trying to extend lines? What errors are you seeing?
I have two questions:
1.Did it take all the "LWPOLYLINE,LINE,SPLINE,CIRCLE" that have been selected as multiple boundaries when I extend the lines? Or if there were some system variables that I can set the extend option of boundaries to "all"? So everything is boundary.
2. Did i have  included "trim" and "extend" inside in this routine?
Thanks!

ronjonp

  • Needs a day job
  • Posts: 7027
Re: multi extend at one time
« Reply #27 on: November 27, 2010, 10:45:06 PM »
I'm not sure I understand your questions. Can you post a sample drawing with the desired results?

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

xiaxiang

  • Guest
Re: multi extend at one time
« Reply #28 on: November 29, 2010, 01:14:01 AM »
I'm not sure I understand your questions. Can you post a sample drawing with the desired results?
At first,feeling so sorry foy my bad EN. :oops:
I just want the result like this(see attached) ,and when I use your mextend.lsp......
Code: [Select]
(defun c:mextend (/ ang c e lines lwp lyr ptlst pts ss)It have been Shown as the Effect like "x1.gif".
I think that there is some matter with multi extend boundaries which selected.
Help!and this is a sample

« Last Edit: November 29, 2010, 01:29:46 AM by xiaxiang »

ronjonp

  • Needs a day job
  • Posts: 7027
Re: multi extend at one time
« Reply #29 on: November 29, 2010, 01:24:29 PM »
I'm not sure I understand your questions. Can you post a sample drawing with the desired results?
At first,feeling so sorry foy my bad EN. :oops:
I just want the result like this(see attached) ,and when I use your mextend.lsp......
Code: [Select]
(defun c:mextend (/ ang c e lines lwp lyr ptlst pts ss)It have been Shown as the Effect like "x1.gif".
I think that there is some matter with multi extend boundaries which selected.
Help!and this is a sample


xiaxiang,

If you want the lines to be within the circles, don't included the polyline in your selection. Just select the circles and one line.

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

Matt__W

  • Seagull
  • Posts: 12954
  • I like my water diluted.
Re: multi extend at one time
« Reply #30 on: November 29, 2010, 01:41:50 PM »
Take a look at the circle all the way to the right.  It starts off empty but ends up with a line inside it.
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

xiaxiang

  • Guest
Re: multi extend at one time
« Reply #31 on: November 30, 2010, 07:50:23 PM »
xiaxiang,

If you want the lines to be within the circles, don't included the polyline in your selection. Just select the circles and one line.
I' m so sorry ,but you misunderstand me due to my bad english  :oops: :oops: :oops:
"x1.gif" is not what I want .It's the effect about which I used your routine.Sorry!
I just want that all the entities(lines,circles,etc.) can be joined end to end.and All Action can be done One step.
I also can do that manually by using trim ,extend and erase command,but just "one step" ,Is it possible?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10366
Re: multi extend at one time
« Reply #32 on: December 01, 2010, 08:51:06 AM »
With lines and not one line with a dashed line type it looks to me like it would take a special
LISP and not one that is designed for general trimming & extending.

Just my opinion.  8-)
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

GDF

  • Water Moccasin
  • Posts: 1992
Re: multi extend at one time
« Reply #33 on: December 01, 2010, 10:15:00 AM »
ronjonp ~ wow  good  

ronjonp  , can you make  this  routine  as your routine  put to practical use

pls see attached image

Looks like your drawing a storefront or curtain wall?

You may want to try out this routine "Curtain Wall (2D)" by Rob Starz:
http://forums.autodesk.com/t5/Autodesk-Architectural-Desktop/Rob-s-routine-of-the-week-curtain-wall/m-p/408872
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2019x64 Windows 10x64

jvillarreal

  • Bull Frog
  • Posts: 312
Re: multi extend at one time
« Reply #34 on: December 01, 2010, 11:51:34 AM »
Xiaxiang,

Ron's routine needs a polyline boundary to extend the linework to..so as-is, you can get your desired result by drawing a polyline boundary enclosing your lines and circles and deleting it afterwards OR by making the two vertical lines polylines and including them in your selection...still less work then all the trimming and extending you would have to do without it.

If you want to do it programmatically, you could search how to create a bounding box out of multiple elements and modify the code to use the bounding box created.

**EDIT**
Also note that by extending multiple lines at the same vertical position, you will end up with overlapping lines.
« Last Edit: December 01, 2010, 12:38:01 PM by jvillarreal »

xiaxiang

  • Guest
Re: multi extend at one time
« Reply #35 on: December 05, 2010, 08:51:42 PM »
Sorry ,I have to give up  :|

ronjonp

  • Needs a day job
  • Posts: 7027
Re: multi extend at one time
« Reply #36 on: December 05, 2010, 10:02:00 PM »
Sorry ,I have to give up  :|

Maybe this will help you. Keep in mind that the circles will need to be visible on the screen.

http://www.theswamp.org/index.php?topic=20164.msg245188#msg245188


Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC