TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started 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 ?
-
Hi,
Here's a way for one boundary.
It's quite more difficult with more boundaries.
(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)
)
-
gile . always thank you
really , you are genius :-) :-) :-)
-
Why automate a built in function?
EXTEND
select boundary objects
FENCE
put in a fence that crosses the lines that you want to extend
-
A little late to the show, but here is my contribution to do multiple boundaries:
(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)
)
-
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~~~
-
:-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
-
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 :)
-
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.
-
ronjonp ~ wow good
ronjonp , can you make this routine as your routine put to practical use
pls see attached image
-
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
-
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.
-
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?
-
Updated code above per Joe's recommendation:
-
Nice
-
Yes, very nice Ron !
-
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.
-
Yes, very nice Ron !
:)
-
A little late to the show, but here is my contribution to do multiple boundaries:
(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?
-
A little late to the show, but here is my contribution to do multiple boundaries:
(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:
-
A little late to the show, but here is my contribution to do multiple boundaries:
(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?
-
Are the objects you're trying to extend lines? What errors are you seeing?
-
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.
-
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?
(while ptlst
(entmakex (list '(0 . "LINE")
(cons 8 lyr)
(cons 10 (car ptlst))
(cons 11 (cadr ptlst))
)
)
(setq ptlst (cddr ptlst))
)
-
cmwade77,
Did you get the layer issue sorted out?
-
Yes, it turned out the layer wasn't changing, but the color (hard coded was).
-
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!
-
I'm not sure I understand your questions. Can you post a sample drawing with the desired results?
-
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......
(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
-
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......
(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.
-
Take a look at the circle all the way to the right. It starts off empty but ends up with a line inside it.
-
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?
-
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-)
-
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
-
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.
-
Sorry ,I have to give up :|
-
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