TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: dussla on February 09, 2008, 10:32:19 AM

Title: multi extend at one time
Post by: dussla 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 ?
Title: Re: multi extend at one time
Post by: gile 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)
)
Title: Re: multi extend at one time
Post by: dussla on February 10, 2008, 08:06:41 PM
gile  .  always  thank you
really , you are   genius  :-) :-) :-)
Title: Re: multi extend at one time
Post by: Bob Wahr 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
Title: Re: multi extend at one time
Post by: ronjonp 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)
)
Title: Re: multi extend at one time
Post by: dussla 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~~~
Title: Re: multi extend at one time
Post by: litss 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





Title: Re: multi extend at one time
Post by: ronjonp 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 :)
Title: Re: multi extend at one time
Post by: Joe Burke 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.
Title: Re: multi extend at one time
Post by: dussla 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
Title: Re: multi extend at one time
Post by: ronjonp 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
Title: Re: multi extend at one time
Post by: Joe Burke 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.
Title: Re: multi extend at one time
Post by: litss 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?  

Title: Re: multi extend at one time
Post by: ronjonp on February 12, 2008, 07:22:22 PM
Updated code above per Joe's recommendation:

Title: Re: multi extend at one time
Post by: Joe Burke on February 13, 2008, 03:40:04 AM
Nice
Title: Re: multi extend at one time
Post by: Kerry on February 13, 2008, 04:28:28 AM

Yes, very nice Ron !
Title: Re: multi extend at one time
Post by: Joe Burke 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.
Title: Re: multi extend at one time
Post by: ronjonp on February 13, 2008, 09:28:43 AM

Yes, very nice Ron !

:)
Title: Re: multi extend at one time
Post by: xiaxiang 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?
Title: Re: multi extend at one time
Post by: ronjonp 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:
Title: Re: multi extend at one time
Post by: xiaxiang 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?
Title: Re: multi extend at one time
Post by: ronjonp on November 12, 2010, 10:13:25 AM
Are the objects you're trying to extend lines? What errors are you seeing?
Title: Re: multi extend at one time
Post by: cmwade77 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.
Title: Re: multi extend at one time
Post by: ronjonp 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))
)
Title: Re: multi extend at one time
Post by: ronjonp on November 18, 2010, 11:33:07 AM
cmwade77,

Did you get the layer issue sorted out?
Title: Re: multi extend at one time
Post by: cmwade77 on November 18, 2010, 12:55:41 PM
Yes, it turned out the layer wasn't changing, but the color (hard coded was).
Title: Re: multi extend at one time
Post by: xiaxiang 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!
Title: Re: multi extend at one time
Post by: ronjonp 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?
Title: Re: multi extend at one time
Post by: xiaxiang 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

Title: Re: multi extend at one time
Post by: ronjonp 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.
Title: Re: multi extend at one time
Post by: Matt__W 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.
Title: Re: multi extend at one time
Post by: xiaxiang 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?
Title: Re: multi extend at one time
Post by: CAB 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-)
Title: Re: multi extend at one time
Post by: GDF 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
Title: Re: multi extend at one time
Post by: jvillarreal 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.
Title: Re: multi extend at one time
Post by: xiaxiang on December 05, 2010, 08:51:42 PM
Sorry ,I have to give up  :|
Title: Re: multi extend at one time
Post by: ronjonp 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