AutoCAD Electrical General Discussion

AutoCAD Electrical General Discussion

Message 1 of 3 (186 Views)

PLC I/O wire number increments

186 Views, 2 Replies
11-21-2003 02:17 AM
Does anyone know how to get a plc i/o wire number to increment after a

I want O:7/0 to go to O:7/0A after a fuse.

Any help will be appreciated.

*Custer, Phil
Message 2 of 3 (186 Views)

Re: PLC I/O wire number increments

11-21-2003 06:27 AM in reply to: *krollenhagen
I have tried to get it to do that but it appears after the first device out
of a PLC
the wire # changes to the default format. I think this is something for
to consider in the next release??

Phil Custer II, PE
Custer Services, Inc.

"krollenhagen" wrote in message
> Does anyone know how to get a plc i/o wire number to increment after a
> termination?
> I want O:7/0 to go to O:7/0A after a fuse.
> Any help will be appreciated.
> Keith
Message 3 of 3 (186 Views)

PLC I/O wire number increments - sample utility

11-21-2003 09:44 AM in reply to: *krollenhagen

You can use this little utility to semi-manually insert incrementing PLC I/O
wire numbers. It's one step above manually typing them in. Cut and paste
below into an ascii text file, call it plcwnum.lsp. Then "APPLOAD" this file
and type plcwnum [enter] at the AutoCAD command line to run. Pick an I/O
address or I/O wire number or I/O connected wire and then
"pick,pick,pick..." the wires that extend out from it. I/O address-based
wire numbers should pop in.

This utility makes use of some of the user "API" calls shown in the on-line
help. I encourage you to enhance it, make it work cooler!


; 20-Nov-03 NEHolt created
; --
(defun c:smileytongue:lcwnum ( / en ed x new_wnum base_wnum ix_cnt index pt1 pt2
pick_xy xitnow ss suffixlst new_wireno ins_xy)
; Semi-automatically insert incrementing I/O address wire numbers
(setq suffixlst (list "A" "B" "C" "D" "E" "F" "G" "H" "J" "K" "L" "M" "N"
"P" "R"))
(while (setq x (entsel "\nSelect MAIN I/O wire connection (LINE wire or
WNUM itself):"))
(setq ix_cnt "")
(setq base_wnum nil)
(setq en (car x))
(setq pick_xy (cadr x)) ; point point
(setq ed (entget en))
((= (cdr (assoc 0 ed)) "INSERT") ; user may have picked on wire number
(setq base_wnum (c:wd_getattrval en "WIRENO*")) ; get wire number
attrib value
(if (AND (not base_wnum)(wcmatch (cdr (assoc 2 ed)) "PLCIO*"))
(progn ; Appears user may have picked on the PLC I/O module
itself. Try an
; auto-repick to see if user picked on a TAGA* I/O address
(if (setq x (nentselp pick_xy))
(progn ; okay, maybe it's our lucky day...
(setq en (car x)) ; picked entity
(setq ed (entget en))
(if (AND (= (cdr (assoc 0 ed)) "ATTRIB")
(wcmatch (cdr (assoc 2 ed)) "TAGA*"))
(progn ; Yes, lucky day. Get I/O address value TAGA*
attribute value
(setq base_wnum (cdr (assoc 1 ed)))
) ) ) ) ) )

((= (cdr (assoc 0 ed)) "LINE") ; user probably picked on line WIRE
; Look for wire number pointer tied to this LINE entity. Points at
; wire number block insert.
(setq wnum_blk_hdl (car (wd_wnet_find_ptr_for_whole_net en)))
(if (AND wnum_blk_hdl (handent wnum_blk_hdl))
(setq base_wnum (c:wd_getattrval (handent wnum_blk_hdl)
(if base_wnum
(progn ; Okay, now prompt user to pick on wires for the incrementing
; I/O address-based wire number assignments.
(setq index 0) ; start at beginning of suffix list
(setq new_wireno (strcat base_wnum (nth index suffixlst)))
(setq xitnow nil)
(while (AND (not xitnow)
(setq x (entsel (strcat "\n Pick wire for wnum
assignment: " new_wireno))))
(setq en (car x))
(setq ed (entget en))
((= (cdr (assoc 0 ed)) "LINE") ; user picked on a "WIRE"
(c:wd_putwnf en new_wireno) ; insert wire number on selected
((= (cdr (assoc 0 ed)) "INSERT") ; user picked on a block insert
; See if lucky and user picked on a wire number block insert.
; name will have a "WD_WN" prefix if it's a wire number block
(if (wcmatch (cdr (assoc 2 ed)) "WD_WN*")
(progn ; yes, user picked the wire number insert. Need to
find the LINE
; wire that it's sitting on.
(setq ins_xy (cdr (assoc 10 ed))) ; XY coord of wire
number block insert
; Set up a diagonal fence to cut across and capture any
; line wire.
(setq pt1 (list (- (car ins_xy) 0.05) (- (cadr ins_xy)
0.05) 0.0))
(setq pt2 (list (+ (car ins_xy) 0.05) (+ (cadr ins_xy)
0.05) 0.0))
(setq ss (ssget "_F" (list pt1 pt2) '((0 . "LINE"))))
(if (/= ss nil)
(progn ; a LINE entity captured.
(setq en (ssname ss 0)) ; first or only LINE captured
(setq ss nil) ; release the selection set
(c:wd_putwnf en new_wireno) ; pop in the wire number
(it should
; update the existing one and reset the component
; connection X?TERMxx attributes that "touch" this
) )
) )

(setq index (1+ index)) ; increment pointer
(if (= index (length suffixlst))
(progn ; no more suffixes remain, exit now
(setq xitnow 1)
(progn ; calculate next wire number
(setq new_wireno (strcat base_wnum (nth index suffixlst)))
) )
; If AcadE had to do a ZOOM extents to follow the wire number
; then variable "Z_prev" will be set to 1. If so, do a ZOOM PREV
to return
; the display to the original position.
(if Z_prev (command "_.ZOOM" "_PREV"))
(setq Z_prev nil)
) )
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions to get help installing your software.

New AutoCAD Electrical Category!

The AutoCAD Electrical forum has moved into it's very own category page, and can no longer be found within the Additional Product Forums.

Manufacturing Community
The Manufacturing Community provides additional access to tips, tutorials, blogs and networking with peers.