Nate Holt's Blog

July 28, 2009

Gerald’s reset-fixed-tag tool – AutoCAD Electrical

Filed under: Electrical — nateholt @ 9:24 pm

fixed2unfixed02A reader looked a recent posting on this blog and had an idea.

He downloaded the posting’s code, modified it, and created a cool, brand-new AutoCAD Electrical productivity tool. Awesome!

Here is what Aceri Nederland’s Gerald te Wierik did with the recent blog posting (Gerald is shown here, at the left, with a big AutoCAD Electrical smile).

 

 

Project Re-tag, Cross-reference, and “Fixed tag” reset tool

Here is what Gerald says about the need for this new tool.

“The goal for this routine was that after generating the drawings with Typical Manager we have to retag the components, except the cables because we can have star/delta motor circuits for example. In that case the same cablename is used multiple times on the parent cable markers. If we reset and retag the complete project we lose the link between those cables.”

The re-tag and the re-cross-reference parts of Gerald’s tool were pretty straightforward. But the missing piece was a need for a way to go through the drawing set and selectively turn any “fixed” component tag attributes back to “normal” EXCEPT FOR cable markers! This basically meant renaming each block instance’s TAG1F attribute back to TAG1 UNLESS the component was a cable marker… in which case the utilty would leave it alone.

A recent posting supplied the basis to solve this missing piece of Gerald’s 3-part utility. It is a blog entry that describes a tool to search for attributes on non-opened drawings and update their values. But Gerald was not interested in changing the TAG1F attribute value, he wanted to change the TAG1F attribute name. So he took this utility and modified it to rename a target attribute instead of changing a target attribute’s value. He only had to modify a small number of lines of code in the original utility to accomplish this new behavior – i.e. flip “fixed” component tags back to nomal tags UNLESS the component is a cable marker symbol.

The small code change to change the utility’s function

Here is the key part of the original blog entry utility:

(while (AND enn_hdl            
  (/= (cdr (assoc 0 edd)) "SEQEND") ; end of this entity            
  (/= (cdr (assoc 0 edd)) "INSERT") ) ; beginning of next!                                       
  (if (AND (= (cdr (assoc 0 edd)) "ATTRIB")           
           (wcmatch (cdr (assoc 2 edd)) target_attrnam))    
    (progn ; yes, found target attribute tag      
      (setq oldval (cdr (assoc 1 edd)))      
      (if (/= oldval newval)                        
        (progn ; Prepare to push new value back out to the attribute          
          (if (setq newedd (subst (cons 1 newval)(assoc 1 edd) edd))            
            (progn             
              (wd_dbx_entmod newedd dwg_hdl) ; push new attribute value out

… and here are the key changes Gerald made to alter what the utility would do (i.e. change attribute tag name instead of changing attribute value):

(while (AND enn_hdl           
            (/= (cdr (assoc 0 edd)) "SEQEND") ; end of this entity            
            (/= (cdr (assoc 0 edd)) "INSERT") ) ; beginning of next!              
  (if (AND (= (cdr (assoc 0 edd)) "ATTRIB")                       
           (= (cdr (assoc 2 edd)) "TAG1F"))
    (progn ; yes, found target attribute tag
      (setq ed (wd_dbx_entget ben_hdl dwg_hdl (list "*"))) ; open the block insert instance
      ; Get block name. Check if it is a parent cable marker (block name = "HW01" or "VW01") 
      (setq blknam (cdr (assoc 2 ed)))     
      (if (not (wcmatch blknam "VW01,HW01"))       
        (progn ; not a parent cable marker, go ahead and flip the "fixed"              
          ; TAG1F attribute tag name to the normal TAG1 attribute name         
          (setq newedd (subst (cons 2 "TAG1")(assoc 2 edd) edd)) ; Change TAG1F into TAG1        
          (wd_dbx_entmod newedd dwg_hdl) ; push new TAG name out

DCL file to create a front-end dialog

Gerald created a small ASCII text file to define a simple dialog for his 3-part tool. Here’s what it looks like when the command is launched with the “fixed” tag reset option highlighted.

fixed2unfixed01

Gerald’s tool – try it

Gerald invites you to give it a try. Download the AutoLisp file here and the supporting dialog DCL file here. Put both files into some folder that is in the AutoCAD support path. APPLOAD the AutoLisp file, then type TNEC [Enter] at your “Command:” prompt. The above dialog should appear (if it does not, then confirm that the DCL file tag_normal_except_cables.dcl is in an AutoCAD support file path).

Here’s is a short Gerald te Wierik bio:  I’m working as support/application engineer at Aceri Nederland BV. Providing demonstrations, consulting, implementation, training and project management for AutoCAD Electrical, Electrical Designer  and Typical Manager. Prior to Aceri I worked for 6 years at an Autodesk Reseller as trainer and support engineer for AutoCAD, AutoCAD Mechanical, Electrical Designer, Engineering and Data management applications.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: