AutoCAD Electrical Forum
Welcome to Autodesk’s AutoCAD Electrical Forums. Share your knowledge, ask questions, and explore popular AutoCAD Electrical topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ACE API problem

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
263 Views, 2 Replies

ACE API problem

I have written a simple program to quickly assign wires to a given layer. I am using the wd_get_wire_netlst function. Everything works fine except the function seems to leave out wire loops. I have listed the code below. I have it called from buttons that pass it a layer name, such as RED_12_THHN. ACE's built in Wire Layer Utility does not have this problem.


(defun c:setwirelayer ( wirelayer / en ed x netlst wirelst wire wired)
(while (setq x (entsel "\nSelect wire to change layer of:"))
(setq en (car x))
(setq ed (entget en))
(if (= (cdr (assoc 0 ed)) "LINE")
(progn ; okay to continue
(if (setq netlst (c:wd_get_wire_netlst en 1))
(progn
(setq wirelst (car netlst))
(foreach wire wirelst
(setq wired (entget wire))
(setq wired (subst (cons 8 wirelayer) (assoc 8 wired) wired))
(entmod wired)
)
)
)
)
)
)
(princ)
)
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

Hi,
Yes, you need to do just a bit more coding. The call you are making returns
the list of wire segments but it doesn't deal with any "loops" that might be
drawn in as well. Here is your program with a check to look for the loops at
each end of each wire segment. See if this gets you closer to what you are
looking for.
Nate.

(defun c:setwirelayer ( wirelayer / en ed x netlst wirelst wire wired)
(while (setq x (entsel "\nSelect wire to change layer of:"))
(setq en (car x))
(setq ed (entget en))
(if (= (cdr (assoc 0 ed)) "LINE")
(progn ; okay to continue
(if (setq netlst (c:wd_get_wire_netlst en 1))
(progn
(setq wirelst (car netlst))
(foreach wire wirelst
(setq wired (entget wire))
(setq wired (subst (cons 8 wirelayer) (assoc 8 wired) wired))
(entmod wired)
; Check each end of wire for an arc "loop"
(setq end1 (cdr (assoc 10 wired))) ; first end
; Throw a small crossing window around this end
; and try to capture an ARC entity
(setq pt1 (polar end1 (* pi 0.25) 0.05)) ; upper right
(setq pt2 (polar end1 (* pi 1.25) 0.05)) ; lower left
(setq ss (ssget "_C" pt1 pt2 '((0 . "ARC"))))
(if (/= ss nil)
(progn ; captured one or more ARC entities at end1
(setq slen (sslength ss)) ; number of ARCs found
(setq ix 0)
(while (< ix slen)
(setq en (ssname ss ix)) ; get next ARC from selection
set
(setq ed (entget en))
(setq ed (subst (cons 8 wirelayer) (assoc 8 ed) ed))
(entmod ed)
(setq ix (1+ ix))
)
(setq ss nil) ; release the selection set
) )
(setq end2 (cdr (assoc 11 wired))) ; second end
; Throw a small crossing window around this end
; and try to capture an ARC entity
(setq pt1 (polar end1 (* pi 0.25) 0.05)) ; upper right
(setq pt2 (polar end1 (* pi 1.25) 0.05)) ; lower left
(setq ss (ssget "_C" pt1 pt2 '((0 . "ARC"))))
(if (/= ss nil)
(progn ; captured one or more ARC entities at end1
(setq slen (sslength ss)) ; number of ARCs found
(setq ix 0)
(while (< ix slen)
(setq en (ssname ss ix)) ; get next ARC from selection
set
(setq ed (entget en))
(setq ed (subst (cons 8 wirelayer) (assoc 8 ed) ed))
(entmod ed)
(setq ix (1+ ix))
)
(setq ss nil) ; release the selection set
) )
)
)
)
)
)
)
(princ)
)



wrote in message news:5047923@discussion.autodesk.com...
I have written a simple program to quickly assign wires to a given layer. I
am using the wd_get_wire_netlst function. Everything works fine except the
function seems to leave out wire loops. I have listed the code below. I have
it called from buttons that pass it a layer name, such as RED_12_THHN. ACE's
built in Wire Layer Utility does not have this problem.


(defun c:setwirelayer ( wirelayer / en ed x netlst wirelst wire wired)
(while (setq x (entsel "\nSelect wire to change layer of:"))
(setq en (car x))
(setq ed (entget en))
(if (= (cdr (assoc 0 ed)) "LINE")
(progn ; okay to continue
(if (setq netlst (c:wd_get_wire_netlst en 1))
(progn
(setq wirelst (car netlst))
(foreach wire wirelst
(setq wired (entget wire))
(setq wired (subst (cons 8 wirelayer) (assoc 8 wired) wired))
(entmod wired)
)
)
)
)
)
)
(princ)
)
Message 3 of 3
Anonymous
in reply to: Anonymous

Yes, that did it. Thanks, Nate!

-Steve

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

Post to forums  

Autodesk Design & Make Report

”Boost