IEC-style Wire Numbering - AutoCAD Electrical

  • Controlling the Machine is no longer being updated. Don't worry, though, you can still follow Nate Holt at his new blog, AutoCAD Electrical Etcetera. You'll find it at http://nateholt.wordpress.com. Or you can subscribe to his feed to get latest words of wisdom automatically: http://nateholt.wordpress.com/feed/. You also can continue to view the Controlling Machine archives for Nate's AutoCAD Electrical tips and tricks.

    About Nate

Latest Post

  • IEC-style Wire Numbering - AutoCAD Electrical
    April 13, 2009, 01:48 PM Nate Holt

    Though not a specific option, IEC-style wire numbering with suppression of INST and LOC prefix values when match drawing defaults is possible. The work-around is described below. 

    The driving force behind this request comes from Miles Nicholson, Aceri UK. His customers often must deal with dozens of repeated, cookie-cutter circuits where wire numbers are to be the same from instance to instance - though the different wire networks with a common wire number are not connected.

    A good example might be repeated, standard circuits found in motor control center documentation. Each circuit is contained within its own "cubical" of the MCC with only a few control wire connections leaving it to go elsewhere. Here is what the customer wants to see for wire numbering:

    The Problem

    Assuming that there are a dozen drawings in the project, each with a circuit as shown above (but with different motor numbers), there are going to be twelve wire number 9's in the project set, twelve wire number 11's in the drawing set, twelve motor leads labeled 2 in the drawing set. AutoCAD Electrical is not going to want to repeat wire numbers.

    Miles' Solution - Step 1

    The first step of the solution is to set up AutoCAD Electrical to add an IEC-style "INST/LOC" prefix to each wire number. The INST and LOC values can be set up as drawing-wide defaults from "Drawing Properties" dialog. For example, the INST value might be "MCC2" to designate that the drawing is associated with Motor Control Center #2. The LOC assignment might be the circuit's cubical location within MCC2. For example, LOC = "C4" might mean that is it in the third vertical section ("C") and the fourth position down from the top (i.e. "4").

    So, for each drawing (one MCC cubical circuit per drawing), the drawing INST/LOC defaults are set up to identify the MCC "installation" and the cubical "location" within the MCC.

    Now, on this same Drawing Properties dialog, Miles sets the wire numbering format to include the IEC "Inst" and "Loc" flags (%I and %L) as a prefix to the generated wire number (the %N part of the wire number tag format).

     

     Now, with all this in place for each drawing that has a cubical schematic drawing, we're ready to do project-wide wire numbering. Since each drawing's INST/LOC combo is unique and each drawing is set to sequential wire numbering starting at "1", Miles ends up with common wire numbering for each circuit except for the INST/LOC prefix. Here is one of the drawings with the unique "=MCC2+C4" prefix on all of the assigned wire numbers.

    Step 2 - Stripping off the LOC and/or INST prefix when match drawing defaults

    Final step requires a small AutoLISP function that makes a number of calls into the AutoCAD Electrical "API". This little tool will process one drawing at a time. It will read the drawing's default INST and LOC assignments (what user previously entered from Drawing Properties dialog and saved on the WD_M block). Then it will process each wire number it finds. It looks for a wire number match on the INST value. If found, it strips that part off of the wire number. Then it does the same for the LOC value. If match, it strips off that too.

    The net result is that any wire number that exactly matches the drawing default's INST/LOC values will end up being restored to a bare wire number. But any wire number that comes from some other location (i.e. will have a different INST/LOC prefix combo), will remain unchanged ( ! ). Pretty cool.

    Here is the little AutoLisp utility. Note that you can modify this utility to either work on all wire numbers or on just those that are not marked "fixed". Comment out the appropriate line, about 18 lines down.

    ; ** 12-Apr-09 NEHolt reworked to look for drawing-wide INST/LOC assignments
    ; ** 16-Feb-08 NEHolt fixed typo in original
    ; -------  W N U M _ R M V _ I E C _ S U F F I X . L S P  ------
    (defun c:rmv ( / ss delim_char slen ix wnum_en pos wen newnum attrname)
      ; PURPOSE: remove IEC wire number suffix when INST/LOC values match up
      ;   with drawing-wide INST/LOC assignments... leaving just bare wire number.
      ;   This works on both normal wire numbers and in-line wire numbers. It updates
      ;   any extra wire number "copies" as well.
      ;   Note: this will process and modify just "normal" (i.e. non-fixed) wire numbers
      ;     unless adjustment made immediately below.
     
    ; ************ 
      ;  To process both normal and "fixed" wire numbers, uncomment line "WIRENO*" and
      ;  comment out the "WIRENO" line.
      ;  To process just "normal" wire numbers and leave "Fixed" untouched, uncomment
      ;  the "WIRENO" line below and comment out the "WIRENO*" line.
      ;  (uncomment just one of the two lines below - remove the line's leading ";" character)
     
    ;  (setq attrname "WIRENO*")  ; uncomment this line to process both normal and fixed
      (setq attrname "WIRENO") ; uncomment this line to process just "normal" (fixed untouched)
     
    ; ************
     
      ; Search for schematic wire number instances. This includes in-line wire number
      ; instances. 
      (setq ss (ssget "_X" '((-4 . "<AND")
                             ( 0 . "INSERT")
                             ( 2 . "WD_WN*")
                             (-4 . "AND>"))))
      (if (/= ss nil)
        (progn ; active drawing carries some wire number instances. Continue.   
          ; Get drawing-wide INST and LOC assignments
          (wd_cfg_read_dwg_params) ; read the WD_M block and set GBL_wd_m global
          (setq inst (nth 52 GBL_wd_m)) ; get INST from drawing properties
          (setq loc (nth 53 GBL_wd_m)) ; get LOC value from drawing properties
         
          (setq slen (sslength ss))
          (setq ix 0)
          (while (< ix slen)
            (setq wnum_en (ssname ss ix)) ; get wire number entity
            (setq ix (1+ ix)) ; increment for next time                        
            ; Get wire number text (either WIRENO* or WIRENO attribute name)
            (if (setq wnum_val (c:wd_getattrval wnum_en attrname))
              (progn
                (setq save_val wnum_val) ; save copy for comparison later
                (if (AND inst (/= inst ""))
                  (progn ; Look for INST prefix on this wire number string           
                    (if (= (substr wnum_val 1 (strlen inst)) inst)               
                      (progn ; Exact match with INST value. Strip it off
                        (setq wnum_val (substr wnum_val (1+ (strlen inst))))
                      )
                    ; ELSE
                      (progn
                        (if (= (substr wnum_val 1 (1+ (strlen inst))) (strcat "=" inst))
                          (progn ; Exact match with "=INST" value. Strip it off.
                            (setq wnum_val (substr wnum_val (+ 2 (strlen inst))))
                ) ) ) ) ) )
                (if (AND loc (/= loc ""))
                  (progn ; Look for LOC prefix on this wire number string           
                    (if (= (substr wnum_val 1 (strlen loc)) loc)               
                      (progn ; Exact match with INST value. Strip it off
                        (setq wnum_val (substr wnum_val (1+ (strlen loc))))
                      )
                    ; ELSE
                      (progn
                        (if (= (substr wnum_val 1 (1+ (strlen loc))) (strcat "+" loc))
                          (progn ; Exact match with "=INST" value. Strip it off.
                            (setq wnum_val (substr wnum_val (+ 2 (strlen loc))))
                        ) )   
                ) ) ) )
                   
                (if (/= wnum_val save_val)
                  (progn ; Something was stripped off. Push bare wire number back
                         ; out to the wire network.
                    ; Remove any leading "-" prefix on the wire number
                    (if (= (substr wnum_val 1 1) "-")(setq wnum_val (substr wnum_val 2)))
                   
                    ; Now get the entity name of the wire that passes under this
                    ; wire number instance.    
                    (if (setq wen (car (c:ace_wnum_find_wire_en wnum_en GBL_wd_trp)))             
                      (progn ; Found it. Push revised wire number back out. Update
                             ; any extra wire number "copies" found on the wire network.
                        (princ "\n")
                        (princ save_val)
                        (princ " --> ")
                        (princ wnum_val)                   
                        (c:wd_putwn wen wnum_val)
            ) ) ) ) ) )
          )
          (setq ss nil)
        )   
      )
      (princ)

    Download it here. files/26701_26800/26711/file_26711.lsp Copy it to some folder that is in your ACAD support path and rename it wnum_rmv_iec_suffix.lsp.

    To make it always available, follow the instructions that Miles shows here:

    Type Appload at the command prompt.
    Under the section StartUpSuite, select Contents
    Select Add
    Browse to the folder where you downloaded the above file.
    Pick the file wnum_rmv_iec_suffix.lsp
    Select Add and then Close

    Now, any time you need the tool to operate on the active drawing, type RMV [Enter] at the command line. You can also run this tool in a project-wide mode. To do this, create a script file with just a single line entry "RMV". Then reference this script file from the "Project-wide Utilities" --> "Run Command Script" edit box.

    0 Comment | Add Comment Controlling the Machine >

Comments



You must be logged in to post a comment.

Subscribe to Blog

Want to keep up with the latest? Subscribe to the RSS feed today.

RSS

Tags

You must be logged in to add a tag.

Send to a Peer

You must login to share pages.

Feedback

Tell us what you think of the site.

Send Feedback