Adding a special cross-ref capability to AutoCAD Electrical

  • Coinciding with the acquisition of VIA Development, Nate joined Autodesk in March of 2003 after a decade stint as an entrepreneur following a two-decade stint as a controls engineer and software applications developer at Owens-Corning. Nate is now the lead product architect for AutoCAD Electrical. He loves this stuff.

    About Nate

Latest Post

  • Adding a special cross-ref capability to AutoCAD Electrical
    March 24, 2009, 02:26 PM Nate Holt

    Cross-reference a schematic parent symbol onto a panel footprint or panel terminal representation. Not supported out-of-the-box, but you can create your own tool to do it!

    This issue was raised by a user who was using AutoCAD Electrical to do instrumentation-type drawings - dealing with junction box wiring diagrams. He wanted to show the terminal strip components as panel terminal symbols but then show a sheet / zone cross-reference text on each panel terminal pointing back at its schematic representation.

    AutoCAD Electrical currently has no provision for pushing cross-reference annotation on to panel footprint or panel terminal symbols. But, when "surfing", the surf window shows both schematic and panel references in its little window. So, the data is available, it's just not being exploited in this particular situation.

    Here's a little utility that may do the job. You pick on panl footprint and panel terminal representations. The utility uses an internal call that the "Surfer" command normally calls. The returned data is parsed to pull out the schematic parent or schematic terminal sheet and zone (line reference) value. Data is then pushed to the picked panel footprint - result is that the panel symbol now carries a reference back to its schematic representation!

    Here's the utility:

    ; ** 24-Mar-09 NEHolt
    ; -------   P A N E L _ C R O S S R E F . L S P  --------
    (defun c:panel_crossref ( / ss active_dwg_INST active_dwg_LOC x tag loc inst
                slen ix ben hit cross_ref_str rec ref str query_data sheet
                termno scratch_fnam panel_xref_attrib_name)
      ; PURPOSE: push schematic parent cross-reference info on to panel footprint
      ;          symbols if target cross-reference attribute is present.
     
      ; Set the target attribute name for this special cross-referencing
      (setq panel_xref_attrib_name "XREF")
     
      ; Get active project's "scratch database" file name
      (if (setq scratch_fnam (c:wd_mdb_get_proj_scratch_dbnam nil))
        (progn ; Now have active project's scratch database filename

          ; Read the active drawing's "WD_M" block values. This will carry
          ; the active drawing's default INST and LOC assignments which
          ; may be needed later.           
          (if (not GBL_wd_m) (wd_cfg_read_dwg_params))
          (setq active_dwg_INST (nth 52 GBL_wd_m))
          (setq active_dwg_LOC (nth 53 GBL_wd_m))     
               
          ; Now prompt user to select footprint and panel terminal symbols
          ; to process.
          (princ "\nSelect footprint and/or panel terminals to process:")
          (setq ss (ssget '((0 . "INSERT")))) ; gather up selected INSERTs
          (if (/= ss nil)
            (progn ; some INSERT instances selected, okay to proceed
               
              ; Begin to process the picked block INSERT instances on active
              ; drawing.
              (setq slen (sslength ss)) ; number of entities picked
              (setq ix 0) ; will be used to index through them
              (while (< ix slen)
                (setq ben (ssname ss ix)) ; get next entity to process
                (setq ix (1+ ix)) ; increment index for next time
                ; Determine what this block insert is
                (setq x (c:wd_is_it_pnl ben))
                (cond
                  ((= x "FP") ; panel footprint
                    (setq tag (c:wd_get_pnlval ben "P_TAG*"))
                    (setq loc (c:wd_get_pnlval ben "LOC"))
                    (setq inst (c:wd_get_pnlval ben "INST"))
                   
                   
                    ; if LOC or INST blank, substitute in the drawing-wide
                    ; default assignment.               
                    (if (= loc "")(setq loc active_dwg_LOC))
                    (if (= inst "")(setq inst active_dwg_INST))
                   
                    ; Call internal "surfer" query function               
                    (setq query_data (wd_surfa_getcmprefs (list tag inst loc) nil nil))
                    ; Sort through returned data. Look for schematic parent
                    (setq hit nil)
                    (foreach rec (car query_data)
                      (if (not hit)
                        (progn
                          ; Format of rec will be: (list type par1chld2 nonc ref sheet ? ? ...)
                          ; where type = "1" for schem parent
                          (if (AND (= (nth 0 rec) "1") ; schematic symbol
                                   (= (nth 1 rec) "1")) ; and it's a parent
                            (progn
                              (setq hit rec)
                    ) ) ) ) )
                    (if hit
                      (progn ; Found match. Format the cross reference text
                        (setq sheet (nth 4 hit))
                        (setq ref (nth 3 hit))
                        (setq cross_ref_str (strcat sheet "/" ref))
                        ; Push cross-ref out to target attribute
                        (if (not (c:wd_modattrval ben panel_xref_attrib_name cross_ref_str nil))
                          (progn ; problem
                            (princ "\nNo ")
                            (princ panel_xref_attrib_name)
                            (princ " attribute found on panel footprint ")
                            (princ tag)
                            (princ " for cross-ref ")
                            (princ cross_ref_str)
                        ) )
                  ) ) )
                  ((= x "FPT") ; panel terminal
                    (setq tag (c:wd_get_pnlval ben "P_TAGSTRIP*"))
                    (setq termno (c:wd_getattrval ben "WIRENO,TERM01,TERM"))
                    (setq loc (c:wd_get_pnlval ben "LOC"))
                    (setq inst (c:wd_get_pnlval ben "INST"))             
                    ; if LOC or INST blank, substitute in the drawing-wide
                    ; default assignment.               
                    (if (= loc "")(setq loc active_dwg_LOC))
                    (if (= inst "")(setq inst active_dwg_INST))
                    ; Call internal "surfer" query function               
                    (setq query_data (wd_surfa_getcmprefs (list tag inst loc) nil "2"))
                    ; Sort through returned data. Look for schematic parent with same terminal
                    ; number value.
                    (setq hit nil)
                    (foreach rec (car query_data)
                      (if (not hit)
                        (progn
                          ; Format of rec will be: (list type ? ? ref sheet ? termno ...)
                          ; where type = "T" for schem terminal
                          (if (AND (= (nth 0 rec) "T") ; schematic terminal
                                   (= (nth 6 rec) termno)) ; match on schem terminal number
                            (progn
                              (setq hit rec)
                    ) ) ) ) )
                    (if hit
                      (progn ; Found match. Format the cross reference text
                        (setq sheet (nth 4 hit))
                        (setq ref (nth 3 hit))
                        (setq cross_ref_str (strcat sheet "/" ref))
                        ; Push cross-ref out to target attribute
                        (if (not (c:wd_modattrval ben panel_xref_attrib_name cross_ref_str nil))
                          (progn ; problem
                            (princ "\nNo ")
                            (princ panel_xref_attrib_name)
                            (princ " attribute found on panel terminal ")
                            (princ termno)
                            (princ " for cross-ref ")
                            (princ cross_ref_str)
                        ) )
                  ) ) )
              ) )
              (setq ss nil) ; release the selection set
          ) )   
      ) )
      (princ)
    )   

    Download a copy here: files/25201_25300/25241/file_25241.lsp  and rename panel_crossref.lsp

    To use:

    1. You need to add attribute XREF to your panel symbol or panel terminal

    2. APPLOAD attached. Type PANEL_CROSSREF [Enter]. Pick on panel footprint or panel terminal symbols.

     

    1 Comment | Add Comment Controlling the Machine >

Comments

  • August 13, 2009 07:41 AM DEEPAK NAGPAL

    Sir,Please provide the reverse too.Xref in schematic of panel component. thankyou Deepak



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