i need some help with trimming unwanted line autolisp

i need some help with trimming unwanted line autolisp

chelseabun
Explorer Explorer
1,725 Views
15 Replies
Message 1 of 16

i need some help with trimming unwanted line autolisp

chelseabun
Explorer
Explorer

hi. i'm a beginner in autocad. i usually need to trim object as in my gif. after using EXTRIM, i have to trim excess line which is in between my wanted line. so i want to find an autolisp can do it for me automatically but can't find it. any help is appreciated. thank you

0 Likes
1,726 Views
15 Replies
Replies (15)
Message 2 of 16

gbattinPH5TG
Advocate
Advocate

After using EXTRIM, use the following Trim Every Other code found here:

https://www.theswamp.org/index.php?topic=42350.msg475290#msg475290

0 Likes
Message 3 of 16

chelseabun
Explorer
Explorer

thanks for your answer. i tested the code but it only keep the line which i clicked on, so it seem not work for me. this gif show my real work. please give me an advise

0 Likes
Message 4 of 16

Sea-Haven
Mentor
Mentor

Try CookieCutter.

 

Ok one way around problem is change the objects inside the circle to a dummy layer and turn off, erase all other objects left behind, turn on and change layer of objects inside circle back to old layer. Yes for a circle need an approximation of the circle as facets. Done via a lisp limited user interaction.

 

 

0 Likes
Message 5 of 16

chelseabun
Explorer
Explorer

thanks for your answer but this lisp delete everything except the one i'm working with. i want to keep wanted line in between deleted line like this gif show

0 Likes
Message 6 of 16

Sea-Haven
Mentor
Mentor

Ok understand I don't know if it can be automated as the length of the removed objects varies, I have used a CAB Breakall.lsp and it finds all the short segments, and you can erase them, but this task has all sorts of varying lengths. 

 

Need a dwg to even start thinking about it. Some one else may also jump in.

0 Likes
Message 7 of 16

chelseabun
Explorer
Explorer

i have tested the break lisp and it give me an idea: convert the circle to arc then use break.lsp, then join arc to polyline but not arc to arc, then filter all arc to delete them. do you know how to join arc to polyline but not arc to arc?

0 Likes
Message 8 of 16

Sea-Haven
Mentor
Mentor

For any one to comment need a dwg.

0 Likes
Message 9 of 16

Kent1Cooper
Consultant
Consultant

@chelseabun wrote:

.... join arc to polyline but not arc to arc, then filter all arc to delete them. do you know how to join arc to polyline but not arc to arc?


I can imagine a way to do that much, using the ends of an Arc as a Fence in (ssget) filtering to find only open Polylines.  But all kinds of complications are possible:

Kent1Cooper_0-1747848298013.png

Suppose the red Arc is the one under consideration.  The method I imagine would be able to find the cyan Polyline [ignoring the white and yellow Arcs to either side] to join the Arc to.  But then, say it moves on to consider the yellow Arc next.  It would find the magenta Polyline, but you don't want those to be joined.  I'm not picturing how a routine could know that it should be considering the green Arc next [to join to the magenta Polyline], instead of the yellow one, so that the yellow one remains as an Arc to be deleted later.  It would need to start with some Arc that resulted from the Breaking routine, but which one?  If it starts with the yellow one, it would presumably join that to both the cyan and magenta Polylines, which you may not want.  But you might, if the red and green should be the ones later deleted.

Even with the every-other approach, I think any configuration could have either of the two possible sets of every-other-Arc be kept and the other set deleted.  Maybe something could be done involving asking the User to pick one of them, either one of those to keep or one to delete.

But then, what should happen if a vertex lands right on an Arc, such as the white parts at the upper right?  Assuming the Breaking routine breaks that white Arc at that corner, then I assume you would want both resulting white Arcs eliminated -- not an every-other approach.

 

Kent Cooper, AIA
Message 10 of 16

chelseabun
Explorer
Explorer

this is my example file

0 Likes
Message 11 of 16

Kent1Cooper
Consultant
Consultant

@chelseabun wrote:

this is my example file


The situation would not always be appropriate for this, but in the rectangular-area part of your sample drawing, since it's all line-segment closures, you can just eliminate the white rectangle from you "extrim" portion, grab all the Polylines that were in it, in a collective window, and in the Properties palette, Misc category, change the Closed line from *VARIES* to Yes.

But that won't do what you want if the Extrim boundary is a Circle [or other thing that includes curves] as in your earlier examples and part of your sample drawing, because it will close all the broken Polylines with line segments.

Kent Cooper, AIA
Message 12 of 16

hamidusman230
Community Visitor
Community Visitor

thanks

0 Likes
Message 13 of 16

chelseabun
Explorer
Explorer

thank for your reply. yeah, i think the lisp should ask user to choose the first arc/line to remove/keep, then the rest should be exercuted automatically clockwise/counter clockwise. in the rare case, the corner of the shape sit right on the arc (actually i haven't met this situtation before) then the lisp might not working as expected but i will fix it in the easy way: auto-trim 2 half of the drawing (first one with red line removed, second one with red line kept), join all line to make closed polyline then replace all open polyline with closed polyline from the other half

0 Likes
Message 14 of 16

chelseabun
Explorer
Explorer

i did as you said and the result is really good althought it still needed to fix manually

chelseabun_2-1747936880122.png

 

 

0 Likes
Message 15 of 16

Sea-Haven
Mentor
Mentor

Closing the plines for the rectang shape seems to work but the circle shape causes problems. Run the code and have a look pretty obvious where it goes wrong.

 

(defun c:clpl ( / ss x obj)
(setq ss (ssget '((0 . "LWPOLYLINE"))))
(repeat (setq x (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq x (1- x)))))
(if (= (vlax-get obj 'closed) 0)
(vlax-put obj 'closed 1)
)
)
(princ)
)

 

Message 16 of 16

chelseabun
Explorer
Explorer

thank you for the lisp. this lisp works like a charm 🙂

0 Likes