Delete outside of multiple polylines in one instance, is this possible?

Delete outside of multiple polylines in one instance, is this possible?

Jonathan.Gray68UQW
Enthusiast Enthusiast
12,015 Views
47 Replies
Message 1 of 48

Delete outside of multiple polylines in one instance, is this possible?

Jonathan.Gray68UQW
Enthusiast
Enthusiast

Hello all, 
I am wondering is there a lisp routine or something that will allow me to select multiple closed polylines and then delete everything outside of these closed polylines in one command? 

 

Please see the screenshots below as well as the corresponding AutoCAD file for any generous help you guys could give me :).  

Also out of curiosity could the inverse of what is shown below be somehow made as well? Where that I select the same 3 closed boundaries and have autocad trim what inside of each of 3 all at the same time? 

0 Likes
12,016 Views
47 Replies
Replies (47)
Message 21 of 48

Sea-Haven
Mentor
Mentor

My $0.05 like others here pick all pline boundaries run etrim or trim using offset of pline , Move the pline and all inside it say to right + 100 on extmax. Repeat for all boundaries.

 

Erase using original extmin & extmax all the rest of objects

 

Move the remaining back to true co-ords again.

 

Have used this type of method succesfully.

 

 

0 Likes
Message 22 of 48

cadffm
Consultant
Consultant

 


@Kent1Cooper wrote:


You would still have the problem described in Message 5

Dear Mr. Cooper 😉

This is clear and not a problem, just one task of the job

and to handle by multiple ways. You know it, i know it

 

I am pretty sure that i am not the only one who are able to use (etrim) without editing, incl. you. 😉

 

 

 

Perhaps we wouldn't use it this way, but neither you nor i have this goal.

It was just a hint for someone who's trying to create quick a solution for it's own

and (etrim) is a function, ready to use for trimming.

 

The next one use CHSPACE,  _-VPORTS-Objects, VPSYNC, Export Layout

 

If results are good enough and performance is better than 'by hand', why not.

For personal use, all allowed.

 

 

 

 

 

 

 

 

 

Sebastian

Message 23 of 48

ВeekeeCZ
Consultant
Consultant

HERE is a screencast showing a different approach. 

Copy the boundaries to a Layout, create VPs, match views, Export to Model. 

It's about a minute of clicking... not something I would want to do 100 times a day, so just showing possible workflow.

It does not look complicated to automate...

Message 24 of 48

cadffm
Consultant
Consultant

LOL, a minute later than my post (ExportLayout).

I tried it yesterday

 

But my way in detail is much simpler:

One Viewport with the whole drawing (or better ZOOM Objects (select the three plines)

CHSPACE

_-vports object  for all plines

vpsync with the overall viewport, delete the overall viewport and ExportLayout.

 

For the most od user this way works good enough i think

and it's easy to use in a macro or (command.

 

Sebastian

0 Likes
Message 25 of 48

parkr4st
Advisor
Advisor

I have been following your other post

https://forums.autodesk.com/t5/autocad-forum/how-to-trim-outside-of-multiple-polyline-boundaries/m-p...

where it is stated 

 

 have tried EXTRIM and the commands in autocad map

what commands in map did you try?

This is a very simple overlay analysis with FDO files.  Was that tried?

0 Likes
Message 26 of 48

Kent1Cooper
Consultant
Consultant

@parkr4st wrote:

I have been following your other post

https://forums.autodesk.com/t5/autocad-forum/how-to-trim-outside-of-multiple-polyline-boundaries/m-p...

where it is stated 

 

 have tried EXTRIM and the commands in autocad map

what commands in map did you try?

This is a very simple overlay analysis with FDO files.  Was that tried?


[The above was in Reply to me, but should have been in Reply to @Jonathan.Gray68UQW , who is the one who stated that.]

Kent Cooper, AIA
0 Likes
Message 27 of 48

Jonathan.Gray68UQW
Enthusiast
Enthusiast

Hey, 

If this was in the GIS world I could do this in 3 seconds... sadly it is not. I am surprised that what I want isn't a common place command that has existed for the last 10 years, lol. 

0 Likes
Message 28 of 48

Jonathan.Gray68UQW
Enthusiast
Enthusiast

Hey Kent! Thanks for sticking with me though all of this.   

What surprises me the most is that my desire isn't a command that was invented 10 years ago. Basically "Cookie cutter trim" of multiple polylines all outside and then the inverse would be nice "Cookie cutter trim" all inside of multiply closed polylines.

0 Likes
Message 29 of 48

hak_vz
Advisor
Advisor

What you simply need is to create selection set from cutting edges. After you run command trim around all cutting edges, you would simply select all what is left inside, and copy it to another file with original coordinates.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 30 of 48

Kent1Cooper
Consultant
Consultant

@Jonathan.Gray68UQW wrote:

.... Basically "Cookie cutter trim" ....


Did you see yesterday's revival of a thread using exactly that terminology?  See >this<.  The revival is someone saying they downloaded that and it worked.  See Message 10 there, where someone asks for what you're looking for -- multiple boundaries.  That cookie-cutter routine doesn't work with more than one, but you could use it on multiple copies of your drawing, and then keep one as the base drawing and Insert [or Copy/Paste the contents from] the rest of them into it.

Kent Cooper, AIA
0 Likes
Message 31 of 48

hak_vz
Advisor
Advisor

Here is a little helper script. It moves all elements inside cutting edge 50000 units to y direction. Just cut around some cutting edge and then use command SELANDMOVE to move all objects inside cutting edge. When finished delete all what is left and return back to original location, 50000 units down.

 

(defun c:selandmove ( / e keyValue lwpolypoints sst pts)
(defun keyValue (key el)(cdr (assoc key el)))
(defun lwpolypoints(e / ent npoints elev pts)
    (setq ent (entget e) pts (list))
    (if (and ent)
        (progn
        
            (if (= (logand (cdr (assoc 70 ent)) 1) 1)(setq p1 (cdr (assoc 10 ent))))
            (setq npoints (keyValue 90 ent) npoints (fix npoints) elev (keyValue 38 ent) i 0)
              (cond (ent
                     (while (setq m (assoc 10 ent) ent (cdr (member m ent)))
                       (setq pts (cons (cdr m) pts))
                     )
                    )
              )
        )
    )
  pts
)
(princ "\nSelect boundary to move inside objects >")
(while (not e)(setq e (car (entsel))))
	(setq 
		pts (lwpolypoints e) 
		sst (ssget "_CP" pts )
	)
	(command "_.move" sst "" '(0 0 0) '(0 50000 0))
(princ)
)

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 32 of 48

Sea-Haven
Mentor
Mentor

Thats similar to what I was suggesting look at the image in my post. Very simple using std trim and fence option. Had problem posting image. Just move all to right inside polygon, then erase the rest move back.

 

screenshot259.png

0 Likes
Message 33 of 48

Sea-Haven
Mentor
Mentor

This seems to work  on sample dwg hard to check , testing in Bricscad was ok and Autocad did not work. so needs more testing.

 

Having problems posting images please look at samples.

 

 

 

;  https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/delete-outside-of-multiple-polylines-in-one-instance-is-this/m-p/9776779/highlight/false#M405195

(defun c:test ( / CO-ORD ENT MAXI MINI OLDSNAP SS X)
(alert "Make sure you only have layers that should be displayed\n \nThis is destructive routine")
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
(setq ss (ssget '((0 . "LWPOLYLINE"))))
(setq maxi (getpoint "\Pick top right cnr"))
(setq mini (getpoint "\nPick bottom left cnr"))
(repeat (setq x (sslength ss))
(setq ent (ssname ss (setq x (- x 1))))
(command "offset" 1.0 ent maxi "")
(setq co-ord (reverse (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (entlast))))))
(setq co-ord (cons (nth (- (length co-ord)1) co-ord) co-ord))
(command "erase" (entlast) "")
(command "offset" 2.0 ent maxi "")
(setq ent2 (entlast))
(command "trim" ent ent2 "" "_F" (foreach pt co-ord (command pt)) "")
(setq ss2 (ssget "_WP" co-ord))
(command "move" ss2 "" (list 0.0 0.0) (list 0.0 5000.0))
)
(command "zoom" "e")
(command "erase" "w" mini maxi "")
(Command "move" (ssget "_W" (getvar 'extmax)(getvar 'extmin)) "" "0.0,5000.0" "0.0,0.0")
(command "zoom" "e")
(setvar 'osmode oldsnap)
(princ)
)
(c:test)

 

 

Message 34 of 48

ВeekeeCZ
Consultant
Consultant

@ВeekeeCZ wrote:

HERE is a screencast showing a different approach. 

... It does not look complicated to automate...


HTH

 
Message 35 of 48

Sea-Haven
Mentor
Mentor

Looking at the problems I am having with Autocad and trim your idea seems the way to go as there is substantial line work to be trimmed. May have another go using your and my code. Needs to do copy not move so will find lines that cross 2 boundary.

0 Likes
Message 36 of 48

Jonathan.Gray68UQW
Enthusiast
Enthusiast

Hello!!!  First thank  you for using your coding abilities to tackle this problem. If I could help you I would but when it comes to coding I have zero skills.   So I just wanted to take the time to say thank you! 

 

Below I am going to write out how I think the lisp should work which might be exactly what you are thinking to, but I just wanted to share this so that I felt like I was doing something at least.    

1. Before running the lisp the user isolates the drawing to the clipping edge layer and the layers that the user wants clipped out of the drawing.  

2. User issues command staring the lisp routine and is now prompted to select the cutting edges. 

 

3. After selecting the cutting edges use is now prompted to select objects on layers that will be trimmed. 

 

4. Next the user is asked to draw a window which will include all objects on the layers that need to be trimmed. 

 

5. The lisp does it magic and the user now has on their screen the linework included inside of the first selected closed boundaries. 

0 Likes
Message 37 of 48

hak_vz
Advisor
Advisor

@Jonathan.Gray68UQWHave you tested my code posted under no 31. I hope @Sea-Haven  will create something for you but you can also use my code how explained in my previous post. Don't expect a lot of automation on trim side since either option with extrim or trim is slow and can choke the app

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 38 of 48

Sea-Haven
Mentor
Mentor

The problem was as you say Bricscad does a progress bar a few seconds to trim , Autocad takes minutes to do the trim, gave up a few times, CTRL ALT DEL

 

Reducing the dwg down to dummy testing works instantly see images. The way around may be to trim an edge at a time not all in one go. Its interesting if you do a manual fence trim Autocad keeps up. May have a play with that.

0 Likes
Message 39 of 48

Jonathan.Gray68UQW
Enthusiast
Enthusiast

Hey!  
Sorry for the super late reply, been busy :(. But you command does help ALOT!  Thank you so much for putting the time into it and sticking with me through this journey.  I believe in the future I will use your code many times as well as the other persons code in this thread to help me out :). 

Thank you.

0 Likes
Message 40 of 48

Jonathan.Gray68UQW
Enthusiast
Enthusiast

Hey there! Thank you for putting time and energy into trying to help me out. I really do mean that!

I made a much simpler drawing to try and test your routine but I am to dumb to figure out the steps. I loaded it correctly of course but after I issue the command it gives me the warning but I am unsure if at this point am I supposed to select the closed boundary lines or select everything on the screen?  Would you be willing to a give me the simple 1, 2, 3 steps that I should do to use  your command because I don't think I am selecting the polylines in the correct order. 

0 Likes