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.
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
Solved by Kent1Cooper. Go to Solution.
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.
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.
@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
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?
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.
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.
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.
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.