Trim many interior lines at once

Trim many interior lines at once

FCort
Collaborator Collaborator
4,899 Views
18 Replies
Message 1 of 19

Trim many interior lines at once

FCort
Collaborator
Collaborator

Hi all,

 

Anyone knows how to trim interior lines all at once?

 

(Please see below picture).

 

0 Likes
4,900 Views
18 Replies
Replies (18)
Message 2 of 19

FCort
Collaborator
Collaborator

ACAD TRIM.jpg

0 Likes
Message 3 of 19

chriscowgill7373
Advisor
Advisor

I'd have to do some searching to see if anyone has a LISP routine out there.  You could use fast trim with edgemode set to 0.  then all you have to do is select the segments you want deleted and it will trim out only those areas.

TRIM <enter>> <enter> click the points you want trimmed.


Christopher T. Cowgill, P.E.

AutoCAD Certified Professional
Civil 3D Certified Professional
Civil 3D 2024 on Windows 10

Please select the Accept as Solution button if my post solves your issue or answers your question.

0 Likes
Message 4 of 19

FCort
Collaborator
Collaborator

Chris,

 

Thank you for the answer, but pick each interior line is time consuming.  The best way it will be to drag a selection window to all the rectangles which are the cutting edges boundary, and then all the interior lines will be trimmed at once.

 

Any suggestion?

0 Likes
Message 5 of 19

Patchy
Mentor
Mentor

Go to this link, get the Mextrim.lsp it does exactly what you need.

Capture.JPG

0 Likes
Message 6 of 19

john.vellek
Alumni
Alumni

Hi @FCort,

 

Perhaps EXTRIM might get you close. I have seen some routines in the past that allow trim objects and then select items within a certain region around a pickpoint.  I suggest you post in the AutoCAD Customization forum to see if someone has a routine that can do this for you.  There is no built-in feature that works this way in AutoCAD.

 

 

Please select the Accept as Solution button if my post solves your issue or answers your question.


John Vellek


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
0 Likes
Message 7 of 19

FCort
Collaborator
Collaborator
Thank you John.
0 Likes
Message 8 of 19

FCort
Collaborator
Collaborator

Thank you @Patchy but that lisp doesn't allow to select many rectangles at once; and also the lisp routine asks to pick the interior of the rectangle, so it will be time consuming because I have a lot of rectangles as cutting edge. I need to select all rectangles at once and the lisp will trim the interior lines.

0 Likes
Message 9 of 19

Kent1Cooper
Consultant
Consultant

I can sort of imagine a not-too-difficult way to get a routine to do that if the line is always perpendicular to the edges it crosses, and they're Polyline rectangles.  Would that always be the case?  If not, it could still be done, I think, but it would be more complicated.

 

Or, if they're Blocks, consider adding a Wipeout to the Block definition, and just mask off the pieces of Line that go behind them, instead of Trimming.  A little use of DRAWORDER in the Block definition and in the drawing should take care of it pretty easily.

 

If the rectangles are made of separate Lines, that's a lot harder to imagine automating....

Kent Cooper, AIA
0 Likes
Message 10 of 19

ВeekeeCZ
Consultant
Consultant

Maybe two steps..., two lisps. Break All Or Some HERE - originaly at the swamp (free registation) or some OTHER places as well and then erase the pieces using SelectByLength.

 

(vl-load-com)

(defun c:SL (/ ss ssp ssn i l len) ;;Select by Length
  (if (and (princ "\nSelect Line, *Polyline or Arc,")
	   (setq ss (ssget "_:L" '((0 . "LINE,*POLYLINE,ARC"))))
	   (princ "\nSelect a PATTERN to determine the length: ")
	   (setq ssp (ssget "_+.:E:S" '((0 . "LINE,*POLYLINE,ARC"))))
	   (setq len (vlax-curve-getDistAtParam (ssname ssp 0) (vlax-curve-getEndParam (ssname ssp 0))))
	   (setq ssn (ssadd)))
    (repeat (setq i (sslength ss))
      (setq sn (ssname ss (setq i (1- i)))
	    l (vlax-curve-getDistAtParam (ssname ss i) (vlax-curve-getEndParam (ssname ss i))))
      (if (and (< l (* len 1.01)) ;fussy 1%
	       (> l (* len 0.99)))
	(ssadd (ssname ss i) ssn))))
  (command "_.REGEN")
  (if ssn
    (sssetfirst nil ssn))
  (princ)
)

 

0 Likes
Message 11 of 19

FCort
Collaborator
Collaborator

@Kent1Cooper the lines are not always perpendicular. The rectangles are one polyline.

 

Also, for this case I can not work with blocks.  

 

Thank you for your time.

 

0 Likes
Message 12 of 19

FCort
Collaborator
Collaborator

Break all lisp is very useful , but still I have to erase manually the internal small lines (the lines are not the same length and the geometry is not always horizontal like in my picture). 

0 Likes
Message 13 of 19

chriscowgill7373
Advisor
Advisor

I don't think there is anything out there that can do what you are asking.  it's too complex.

Are all the areas you are trimming within closed polylines?  Are you trimming everything within the objects?

If so, perhaps it could be done.  you could pass the boundaries of the closed polyline one at a time and trim everything inside, possibly modifying extrim to automatically be able to determine the interior point based on the coordinates of the verticies.


Christopher T. Cowgill, P.E.

AutoCAD Certified Professional
Civil 3D Certified Professional
Civil 3D 2024 on Windows 10

Please select the Accept as Solution button if my post solves your issue or answers your question.

0 Likes
Message 14 of 19

FCort
Collaborator
Collaborator

I want to do what I showed in the picture, that means keep everything , just eliminate the lines inside the rectangles.

0 Likes
Message 15 of 19

ВeekeeCZ
Consultant
Consultant

@FCort wrote:

Break all lisp is very useful , but still I have to erase manually the internal small lines (the lines are not the same length and the geometry is not always horizontal like in my picture). 


Sure. It would be helpful show some activity from your side as well. You may start with posting a real dwg instead of jpg (how would you appreciate if I've post a photo of a solution?). A dwg should show us what type of entities you use, what layers (if any), what variaty of shapes we need to cover... But whatever... the following code will help you with selection the pieces inside of curves.

 

(vl-load-com)

(defun c:SelectInside ( / *error* area en en1 enl i l s+ sn ss) ; without objects touching boundary from outside

  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (princ))
  
  (if (and (setq ss (ssget '((0 . "LWPOLYLINE") (-4 . ">") (90 . 2))))
	   (vl-cmdf "_.ZOOM" "_Ob" ss "")
	   (setq sn (ssadd))
	   )
    (repeat (setq i (sslength ss))
      (setq area (vlax-curve-getArea (setq en (ssname ss (setq i (1- i))))))
      (or (and (setq enl (entlast))
	       (vl-catch-all-apply 'vla-offset (list (vlax-ename->vla-object en) (* area 0.001)))
	       (setq en1 (entlast))
	       (not (equal enl en1))
	       (or (< (vlax-curve-getArea en1) area)
		   (progn (entdel en1) nil))
	       )
	  (and (setq enl (entlast))
	       (vl-catch-all-apply 'vla-offset (list (vlax-ename->vla-object en) (* area -0.001)))
	       (setq en1 (entlast))
	       (or (not (equal enl en1))
		   (setq en1 nil))
	       ))
      (if (and en1
	       (entget en1)
	       (setq s+ (ssget "_CP" (mapcar '(lambda (y) (trans y 0 1))
					     (mapcar 'cdr
						     (vl-remove-if-not '(lambda (x) (= (car x) 10))
						       (entget en1))))))
	       (entdel en1)
	       )
	(repeat (setq l (sslength s+))
	  (ssadd (ssname s+ (setq l (1- l))) sn)))))

  (command "_.ZOOM" "_P")
  (sssetfirst nil sn)
  (princ)
)
0 Likes
Message 16 of 19

john.vellek
Alumni
Alumni

HI @FCort,

 

I am checking back to see if my post or others helped you with your problem. Please add a post with how you decide to proceed and your results so other Community members may benefit. If you like, I can move this thread to the Customization forum for you as well.

 

Please hit the Accept as Solution button if a post or posts solves your issue or answers your question.

 


John Vellek


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
0 Likes
Message 17 of 19

greg_battin
Advocate
Advocate

The "Break All or Some" routine from CAB has a remove every other option.

Use the command "BREAKREMOVE" and see that does the trick.

 

"c:BreakRemove - Break selected object with any objects that touch it & remove
                        every other new segment, start with selected object"

 

~Greg

0 Likes
Message 18 of 19

FCort
Collaborator
Collaborator

Please see the attached file.

 

*Ideally a quick window or fence selection of all rectangles as cutting edge, then select the lines and automatic trims all interior lines. 

0 Likes
Message 19 of 19

john.uhden
Mentor
Mentor

I have read all the responses and I think I have it figured out.  Just don't have the time to write.  Maybe someone else can.

 

Steps (all done via lisp).

1.  Select the trim boundaries (as you point out they will all be closed polylines).

2.  Select the line to trim.

3.  Find all the intersection points.

4.  Sort the points by distance from the furthest left to right (or bottom to top)

5a.  Trim the line at a point between each pair of intersections.

  OR

5b.  Entmake a new set of lnes in place of the original. Entdel the original of course.

 

This presumes that the polyline boxes will provide only two intersections each, so we can deal with pairs.

We will have to watch out for if the line starts or ends inside of the first or last polyline box.

 

Okay, @ВeekeeCZ@Kent1Cooper, @RanjitSingh, @SeeM67, put it to music.

John F. Uhden

0 Likes