drawings containing arcs representing wiring. I want to be able to select an arc and find every similar arc that shares one endpoint, as if it were a polyline. however, it is possible for more than two arcs to share an endpoint, and I would want them all.
similar to pedit, but not quite.
so far, I make a selection set of all the possible arcs with ssget "X", and pick the arc for one end. remove it from the selection set. then I process the entire selection set, and every time I find an endpoint that matches the "tail" of the first, I ssdel that from the selection set and add that entity's ename to a list.
(defun c:head_rak (/)
(setq pwr_arcs (ssget "X" '((0 . "ARC")(8 . "PRWIRE"))))
(setq enm (car (setq it (entsel "Pick arc:")))
ent (entget enm)
c1 (cdr (assoc 10 ent))
rad (cdr (assoc 40 ent))
pt1 (polar c1 (cdr (assoc 50 ent)) rad)
pt2 (polar c1 (cdr (assoc 51 ent)) rad)
)
(if (< (distance pt1 (cadr it)) (distance pt2 (cadr it)))
(setq tail pt2
head pt1
ang (- (cdr (assoc 50 ent)) (* pi 0.5))
)
(setq tail pt1
head pt2
ang (+ (cdr (assoc 51 ent)) (* pi 0.5))
)
)
(entmake (list (cons 0 "INSERT")
(assoc 8 ent)
(cons 100 "AcDbBlockReference")
(cons 2 "ar_head")
(cons 10 head)
(cons 50 ang)
)
)
(ssdel enm pwr_arcs)
(setq circuit (list (list enm))) ;; begin list of arcs for this circuit.
(setq i (sslength pwr_arcs))
(repeat i
(setq i (- i 1)
ent (entget (ssname pwr_arcs i))
c1 (cdr (assoc 10 ent))
rad (cdr (assoc 40 ent))
pt1 (polar c1 (cdr (assoc 50 ent)) rad)
pt2 (polar c1 (cdr (assoc 51 ent)) rad)
)
(if (equal (distance pt1 tail) 0 0.1)
(progn
(ssdel (ssname pwr_arcs i) pwr_arcs)
(setq tail pt2)
(setq leg (cons (list (ssname pwr_arcs i)) leg))
;; maybe not cons
)
)
(if (equal (distance pt2 tail) 0 0.1)
(progn
(ssdel (ssname pwr_arcs i) pwr_arcs)
(setq tail pt1)
(setq leg (cons (list (ssname pwr_arcs i)) leg))
)
)
);; repeat
)
it is in my mind to use a while statement. the positive results from the first search get saved in
leg, which would be a list of arcs which also need to be checked for shared endpoints. while there is an ename in
leg, I process entities from that list, and at the end of each process, that ename is deleted from
leg, and added to
circuit.
when only one arc segment is found to match, the list only has one item. but if it finds two, it will continue until both are processed.
seems like it should work, but while statements, I am not good with, normally. I am going to try to finish this up, and I might get it. but if anyone sees I have already gone astray, or that I am really doing something the hard way............