Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LISP for Electrical Plan wiring intersections

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
Libbya
4230 Views, 10 Replies

LISP for Electrical Plan wiring intersections

As part of a construction drawing plan set, my office provides electrical plans.  We map out the building's wiring at the 1:1 scale using arcs.  When two arcs intersect where there is not an electrical connection, we draw a 4" diameter circle around the intersection, trim the circle on one side of one of the polylines and trim the same polyline within the circle.  The result is a little bump in one of the arcs that denotes the fact that there is not an electrical connection there.  I am not very well versed in LISP but would like to create the code necessary to select the intersection, select the arc to trim and the side of the arc to trim the circle and then have it automatically draw the circle on the correct 'E-wiring' layer, trim the arc within the circle, trim the circle on the correct side of the arc and exit going back to the correct layer.  

 

Here is my code so far.

(defun c:WT (/ atrim ci1 int cl)
(setq os (getvar "osmode"))
(setvar "osmode" 32)
(setq int (getpoint "\nSelect intersection"))
(setq atrim (nentsel "\nSelect arc to trim"))
(setq cl (getvar "clayer"))
(command "-layer" "m" "E-Wiring" "c" "152" "" "l" "CENTER2" "" "")
(command "circle" int "2")
(setvar "clayer" cl)
(setvar "osmode" os)
(princ)
)

 

 At this point it draws the circle at the intersection.  I am a little stuck not knowing how to 'select side of circle to trim' and how to get it to trim that side and also how to trim the arc within the circle.  Any suggestions?  One potential wrench in the works is that the wiring will potentially be on top of other linework that cannot be trimmed.  Attached is a file that shows the wiring arcs and one of them trimmed in the correct manner.  Any help is appreciated.

10 REPLIES 10
Message 2 of 11
Kent1Cooper
in reply to: Libbya

Since your description of the steps includes three selections in any case [the intersection, the Arc (or Polyline or whatever) to break, and the portion of the Circle to remove], would you settle for making the second and third selections after the drawing of the Circle, from inside a couple of Trim commands?  The only difference other than the order of the steps is that it requires you to select the wire to be trimmed inside the Circle, not just anywhere.  Minimally tested:

 

(defun c:WT (/ os cl wire)
  (setq
    os (getvar "osmode")
    cl (getvar "clayer")
  )
  (setvar "osmode" 32)
  (command
    "_.layer" "m" "E-Wiring" "c" "152" "" "l" "CENTER2" "" ""
    "_.circle" (getpoint "\nSelect intersection") "2"
  )
  (setvar "osmode" os)
  (setvar "clayer" cl)
  (setq wire (entsel "\nSelect wire to trim, inside Circle: "))
  (command
    "_.trim" (entlast) (car wire) ""
    (cadr wire)
    (getpoint "\nPortion of Circle to remove: ")
    ""
  ); command
  (princ)
)

 

You may want to turn off positional Snap if you use that, and other refinements could be added.

Kent Cooper, AIA
Message 3 of 11
Libbya
in reply to: Kent1Cooper

That works very well.  Thanks you.  The only 'improvement' I can see would be if you missed on your circle or wire selection it would make the first point of a crossing window instead of causing the command to fail but that's a small thing.

Message 4 of 11
Kent1Cooper
in reply to: Libbya


@Libbya wrote:

That works very well.  Thanks you.  The only 'improvement' I can see would be if you missed on your circle or wire selection it would make the first point of a crossing window instead of causing the command to fail but that's a small thing.


Here's a version that at least ensures that the User picks something, though it doesn't know any more than that.  It could be made to check whether what's picked for the wire is a Breakable object and is in fact one that goes through the selected intersection, and even that the selection of the portion of the Circle to remove is actually the just-drawn Circle.  Another possible enhancement -- if there is no intersection within Osnap range of the point selected when it's asking for an intersection, it draws a Circle anyway, in the wrong place.  It could probably be made to ensure that an intersection was found, even an intersection of two Breakable objects, and if not, ask again, if you want.

 

(defun c:WT (/ os cl wire circ)
  (setq
    os (getvar "osmode")
    cl (getvar "clayer")
  ); setq
  (setvar "osmode" 32)
  (command
    "_.layer" "m" "E-Wiring" "c" "152" "" "l" "CENTER2" "" ""
    "_.circle" (getpoint "\nSelect intersection") "2"
  ); command
  (setvar "osmode" os)
  (setvar "clayer" cl)
  (while
    (not (setq wire (entsel "\nSelect wire to trim, inside Circle: ")))
    (prompt "\nMissed -- try again.")
  ); while
  (redraw (car wire) 3); highlight it
  (while
    (not (setq circ (entsel "\nPortion of Circle to remove: ")))
    (prompt "\nMissed -- try again.")
  ); while
  (command "_.trim" (entlast) (car wire) "" (cadr wire) (cadr circ) "")
  (princ)
); defun

Kent Cooper, AIA
Message 5 of 11
Libbya
in reply to: Kent1Cooper

That's perfect.  No need to look any further than that.  Thanks.

Message 6 of 11
bsmithsonVMD7M
in reply to: Libbya

This is exactly what I have been looking for for low voltage system designs! Thank you for the code. How would I modify this to be able to change the circle diameter?

Message 7 of 11
Libbya
in reply to: bsmithsonVMD7M

The "2" in this line sets the radius of the circle:

 

  "_.circle" (getpoint "\nSelect intersection") "2"

 

Change that to whatever value you want for the radius.

Message 8 of 11
bsmithsonVMD7M
in reply to: Libbya

I appreciate you!
Message 9 of 11
Sea-Haven
in reply to: Libbya

Just a comment not sure but sometimes its better to use a wipeout rather than break, then the pline is not actually broken, a wipeout for  circle solution is well known. 

Message 10 of 11
Libbya
in reply to: Sea-Haven

I appreciate the suggestion but for me, in this case, the LISP works considerably better than a wipeout.  I have been using it for the last 7 years and it is an excellent time saver.  I assume your alternative suggestion is to create a wipeout, make sure the draworder has that in front of the wire to be hidden but below the line I want displayed, then create a semi-circle to surround the wipeout on the side I want displayed.  That is considerably more cumbersome than the lisp process.  If the line ever needs to be connected again (quite rare) it is a considerably less complicated process.  

Message 11 of 11
Sea-Haven
in reply to: Libbya

Its just really in the case of where say get length is involved. Just do a polygon based on circle with say 10 sides that is enough normally to use for a wipeout, if doing lots would make a defun to do that bit. Note Bricscad is different polygon sequence. Yes your correct user's choice.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost