Jump to content

A LISP routine to break intersecting lines with a symbol


Adham Magdy

Recommended Posts

Hi.. I'm making electrical shop drawings in Autocad and when there are two intersecting lines (wires) I have to put a cutting symbol at one of them and trim the line.. this could happen hundreds of times in a plan drawing..

I created a cutting symbol block and then I insert it manually at each line intersection, rotate it as needed, and then trim the crossing lines manually.. I tried to use the AutoBlockBreak.lsp but it trims all the lines passing through the block.. and I tried putting a wipeout in the block to hide one line but it always hides all.. so is there a way to quickly break the intersecting lines with a symbol while keeping non-intersecting lines connected?

 

 

 

I've attached a drawing with examples..

Thanks

Drawing1.dwg

Screenshot 2021-11-29 163649.jpg

Edited by Adham Magdy
Link to comment
Share on other sites

  • Adham Magdy changed the title to A LISP routine to break intersecting lines with a symbol

For my architectural lighting / switching plans, I use a block with a masking wipeout between the pair of lines to hide the wire below. Avoids the need to trim.

  • Thanks 1
Link to comment
Share on other sites

14 hours ago, dan20047 said:

For my architectural lighting / switching plans, I use a block with a masking wipeout between the pair of lines to hide the wire below. Avoids the need to trim.

It should work but changing the line order to only hide a line and leave the other is a bit time consuming since many lines are on the same layer..

Link to comment
Share on other sites

16 hours ago, Tharwat said:

I already have wiring program and used a lot in Electrical field and also have the Break button to break wires based on the length the use specifies.

https://autolispprograms.wordpress.com/wiring-program/

I downloaded the trial version but it doesn't automatically put a crossing block and also it doesn't work well with curved buildings which need angles with non orthogonal routing

Link to comment
Share on other sites

3 hours ago, Adham Magdy said:

I downloaded the trial version but it doesn't automatically put a crossing block and also it doesn't work well with curved buildings which need angles with non orthogonal routing

It does not add any crossing block but as I already mentioned in my previous post that you can BREAK the wire lines although this option is not available in the trial version but in the permanent one.

  • Thanks 1
Link to comment
Share on other sites

8 hours ago, Adham Magdy said:

It should work but changing the line order to only hide a line and leave the other is a bit time consuming since many lines are on the same layer..

 

There is some work, I assume you could have a priority of lines that makes sorting easier. For intersections w/unequal number of lines, you could either scale the block disproportionately, or create blocks with varying ratios.

 

 

break.gif

Edited by dan20047
(fix draworder)
Link to comment
Share on other sites

Does the AutoCAD Electrical toolset do this? Seems to me it does, I lost the use of mine when they put 32-bit office on my new computer.

 

I need to put in for IT to give me the 64-bit Office so I can go back to using it.

 

I used use a LISP for doing similar in P&IDs, it should be here on CADTutor. I'll see what I can find.

  • Thanks 1
Link to comment
Share on other sites

Try inserting block with wipeout, but send to back using draw order, you may have to draw order the wire 1st, then the block its a sequence thing of draw order, have used on images old with new portion over top. 3 objects.

  • Thanks 1
Link to comment
Share on other sites

12 hours ago, SLW210 said:

The automatic block break works great and also rotates the object.. but it breaks all the lines passing through the block but maybe it can be modded to only break the lines horizontal to the inserted block and ignore other angles, so it only breaks the line on both sides of the block..

Screenshot 2021-12-01 095643.jpg

Edited by Adham Magdy
Link to comment
Share on other sites

17 hours ago, ronjonp said:

There is also this .. if you can stomach hops :)

 

I love it.. I'll just need to make the hops bigger to be visible on the scale I work on

Link to comment
Share on other sites

11 hours ago, Adham Magdy said:

I love it.. I'll just need to make the hops bigger to be visible on the scale I work on

Change this number whatever you need in the code.

(setq a 0.125)

Alternatively if you use dimscale for scaling:

(setq a	(if (= 0 (getvar 'dimscale))
	  0.125
	  (* 0.125 (getvar 'dimscale))
	)
)

Or if you want to go the mask route with a block:

(defun c:hops (/ a b e pts s x)
  ;; RJP » 2019-01-21
  ;; Creates hops on a selection of intersecting polylines
  (setq a 0.125)
  (setq	a (if (= 0 (getvar 'dimscale))
	    a
	    (* a (getvar 'dimscale))
	  )
  )
  (cond	((null (tblobjname "block" "RJP_WipeOut"))
	 (entmake '((0 . "BLOCK")
		    (100 . "AcDbEntity")
		    (67 . 0)
		    (8 . "0")
		    (100 . "AcDbBlockReference")
		    (2 . "RJP_WipeOut")
		    (10 0. 0. 0.)
		    (70 . 0)
		   )
	 )
	 (entmake '((0 . "LWPOLYLINE")
		    (100 . "AcDbEntity")
		    (67 . 0)
		    (8 . "0")
		    (62 . 7)
		    (420 . 16777215)
		    (100 . "AcDbPolyline")
		    (90 . 2)
		    (70 . 129)
		    (43 . 0.5)
		    (38 . 0.)
		    (39 . 0.)
		    (10 -0.25 0.)
		    (40 . 0.5)
		    (41 . 0.5)
		    (42 . 1.)
		    (91 . 0)
		    (10 0.25 0.)
		    (40 . 0.5)
		    (41 . 0.5)
		    (42 . 1.)
		    (91 . 0)
		   )
	 )
	 (entmake '((0 . "ENDBLK") (100 . "AcDbBlockEnd") (8 . "0")))
	)
  )
  (cond
    ((and (setq s (ssget ":L" '((0 . "lwpolyline"))))
	  (> (sslength s) 1)
	  (setq s (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))))
	  (setq b s)
     )
     (foreach e	s
       (if (setq pts (apply 'append
			    (mapcar '(lambda (x) (vlax-invoke e 'intersectwith x acextendnone))
				    (setq b (cdr b))
			    )
		     )
	   )
	 (while	(caddr pts)
	   (entmake (list '(0 . "INSERT")
			  '(8 . "Mask")
			  '(2 . "RJP_WipeOut")
			  (cons 10 (mapcar '+ pts '(0 0 0)))
			  (cons 41 a)
			  (cons 42 a)
			  (cons 43 a)
			  '(50 . 0.)
		    )
	   )
	   (setq pts (cdddr pts))
	 )
       )
     )
    )
  )
  (princ)
)
(vl-load-com)

 

2021-12-01_12-46-23.gif

Edited by ronjonp
  • Thanks 1
Link to comment
Share on other sites

36 minutes ago, ronjonp said:

Change this number whatever you need in the code.


(setq a 0.125)

Alternatively if you use dimscale for scaling:


(setq a	(if (= 0 (getvar 'dimscale))
	  0.125
	  (* 0.125 (getvar 'dimscale))
	)
)

Or if you want to go the mask route with a block:


(defun c:hops (/ a b e pts s x)
  ;; RJP » 2019-01-21
  ;; Creates hops on a selection of intersecting polylines
  (setq a 0.125)
  (setq	a (if (= 0 (getvar 'dimscale))
	    a
	    (* a (getvar 'dimscale))
	  )
  )
  (cond	((null (tblobjname "block" "RJP_WipeOut"))
	 (entmake '((0 . "BLOCK")
		    (100 . "AcDbEntity")
		    (67 . 0)
		    (8 . "0")
		    (100 . "AcDbBlockReference")
		    (2 . "RJP_WipeOut")
		    (10 0. 0. 0.)
		    (70 . 0)
		   )
	 )
	 (entmake '((0 . "LWPOLYLINE")
		    (100 . "AcDbEntity")
		    (67 . 0)
		    (8 . "0")
		    (62 . 7)
		    (420 . 16777215)
		    (100 . "AcDbPolyline")
		    (90 . 2)
		    (70 . 129)
		    (43 . 0.5)
		    (38 . 0.)
		    (39 . 0.)
		    (10 -0.25 0.)
		    (40 . 0.5)
		    (41 . 0.5)
		    (42 . 1.)
		    (91 . 0)
		    (10 0.25 0.)
		    (40 . 0.5)
		    (41 . 0.5)
		    (42 . 1.)
		    (91 . 0)
		   )
	 )
	 (entmake '((0 . "ENDBLK") (100 . "AcDbBlockEnd") (8 . "0")))
	)
  )
  (cond
    ((and (setq s (ssget ":L" '((0 . "lwpolyline"))))
	  (> (sslength s) 1)
	  (setq s (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))))
	  (setq b s)
     )
     (foreach e	s
       (if (setq pts (apply 'append
			    (mapcar '(lambda (x) (vlax-invoke e 'intersectwith x acextendnone))
				    (setq b (cdr b))
			    )
		     )
	   )
	 (while	(caddr pts)
	   (entmake (list '(0 . "INSERT")
			  '(8 . "Mask")
			  '(2 . "RJP_WipeOut")
			  (cons 10 (mapcar '+ pts '(0 0 0)))
			  (cons 41 a)
			  (cons 42 a)
			  (cons 43 a)
			  '(50 . 0.)
		    )
	   )
	   (setq pts (cdddr pts))
	 )
       )
     )
    )
  )
  (princ)
)
(vl-load-com)

 

2021-12-01_12-46-23.gif

Thanks.. this helps greatly

Link to comment
Share on other sites

On 12/1/2021 at 2:55 AM, Adham Magdy said:

The automatic block break works great and also rotates the object.. but it breaks all the lines passing through the block but maybe it can be modded to only break the lines horizontal to the inserted block and ignore other angles, so it only breaks the line on both sides of the block..

Screenshot 2021-12-01 095643.jpg

 

Perhaps contact Lee Mac directly on his site.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...