-
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.
-
1-line Diagrams and linked MCC layouts: AutoCAD Electrical
February 22, 2007 08:36 PMby Nate HoltA user wanted to create 1-line diagrams and Motor Control Center (MCC) layouts and somehow link them using AutoCAD Electrical. This was a recent posting on the AutoCAD Electrical section of the Autodesk Discussion Groups forum http://discussion.autodesk.com/index2.jspa?categoryID=13. It's a cool idea and the discussion group response is repeated below, but with a bit more detail.
The "link" would minimally enable MCC unit annotation from a simple pick list of 1-line assignments, allow the MCC nameplate assignments to automatically update with changes on the one line diagram, provide "surfing" between the two types of drawings, and give a simple way to auto-generate a nameplate report.
AutoCAD Electrical in not set up, out-of-the-box, to deal with 1-line diagrams and MCC unit assignments. But with some tweaking and a custom "child" library symbol, a minimum implementation is possible. Here's one way to do it...
Step 1 : Each one-line circuit representation needs to have a "parent" symbol (example below, each motor symbol is a "parent" and each disconnect is a parent)

...but the MCC drawing can be just dumb lines and such at this point.

Step 2: Create a generic "child" MCC unit-ID symbol. This is nothing more than a collection of attributes with some marked visible and others marked invisible. The visible attributes are positioned so that the symbol's insertion point will correspond to the upper left-hand corner of its MCC unit. We're re-using the AutoCAD Electrical "INST" attribute to be the MCC unit number. (If you are operating with the European IEC tagging mode, then you'll need to use some attribute other than "INST", maybe "RATING12" or some other unused attribute).

Step 3: With both the 1-line drawings and the MCC layout drawing included in your active AutoCAD Electrical "project", make the MCC layout drawing active on your screen. Use the normal AutoCAD Electrical "Insert Component" command to insert the above unit-ID symbol at the corner of each unit in the MCC layout.
Here we show inserting the first instance of this child symbol at the upper left-hand corner of the first MCC unit in the MCC's second section. It pops in with default "000" (this is what is set up as default on the child symbol's "INST" attribute definition).

When the Edit dialog displays, pick the list "Project" to pick from the list of equipment depicted on the 1-line diagram. Since this unit-ID is a "child" symbol, we want to link it back to the selected parent on the 1-line diagram. This pick list makes it easy to do.

When you pick on the 1-line reference in the list and hit OK, the data from the selected parent on the 1-line diagram gets transferred over to the child here on the MCC layout. Best of all, a smart link is now established between the 1-line symbol and the unit in the MCC (based upon a match on the TAG1/TAG2 attribute values).

Repeat this process for each unit in this second MCC section: insert the child symbol, pick from the project list to get the one line parent, type in the unit ID into the "INST" edit box, and hit OK.

That's about it. The link is established by the equipment TAG1 attribute value on the 1-line "parent" representation getting passed over to the TAG2 attribute on the "child" unit-ID symbol. With this in place, parent--> child updates, surfing, and reporting are all enabled.
Bonus: Let's extract a report from our MCC layout that gives equipment tags, unit numbers and the three lines of nameplate label text for each unit in our MCC layout.
Step 1: With the MCC layout drawing active, select the Schematic Reports command > Component report. Make sure you toggle ON the "Include children" option. Select "Active Drawing" and hit OK.
Step 2: When the report displays, select "Change Report Format" and make sure you show INST, TAGNAME, and DESC1-3 fields to report. Hit OK. There it is!

Select "Change Report Format" again and adjust the column labels. Change "INST" to "UNIT REF" and "TAGNAME" to "EQUIP NO.".

You can even insert this report on the drawing as a table. Pretty neat.
-
Creating Special Wire From/To Annotation - AutoCAD Electrical
February 21, 2007 07:45 PMby Nate HoltThis was an interesting request originating from the gas/oil industry. The user wanted the control schematics to be annotated with individual from and to tags. For example, let's say a pushbutton is shown wired to a motor starter coil and then jumpered down to a pilot light. The "wire tag" of the wire end at the pushbutton would show the tag-ID and pin number of the motor starter coil. The same for the jumpered pilot light. The motor start coil's pin would be tagged with both the pushbutton and the pilot light since is is common to both.
Example: BEFORE

AFTER

AutoCAD Electrical API to the Rescue (again)
Well, out-of-the box, AutoCAD Electrical is not set up to annotate the schematics this way. It has the data and can REPORT these connections this way. But it is not set up to actually INSERT pieces of "smart" from/to text right on each connection of the schematics.
What we want is this:
1. Insert the annotation at the wire connection points, justify and rotate to follow the connected wire.
2. Annotation to follow the same as a from/to report taking into account any special "wire sequencing" overrides or source/destination arrow connections.
3. Text can be manually repositioned.
4. Text will be "smart" in that it can be updated if connections changed - even if the text is moved.
5. Text put on its own layer so it can be turned off (i.e. layer "frozen").
Here is a small AutoLisp utility that is roughed out to provide the above. If you want to give it a try, download the file, APPLOAD it, and type OTHER_END [Enter] at your command line. The active drawing should update.
How it works
Key snippets of the utility are shown below.
Step 1: Extract all wire from/to connection data for the active drawing.

Step 2: Create a selection set of all block insert instances found on active drawing.

Step 3: Loop through the selection set, find schematic "components" blocks with wire connections. Format the connection information into a short string of text.

Step 4: Insert TEXT entity with the formatted text.

Step 5: Flip the new text entity to the target layer. Then insert an Xdata pointer on the wire connection point that points back at this new TEXT entity.

How can I make this Cooler?

Don't be afraid to modify this utility to fit your wants/needs. For example, you might want it to insert multi-line MTEXT instead of a single line TEXT entity. Maybe you'd rather have it insert a "LEADER" entity. How about adding more info to the text, like wire type or include the INST/LOC values in the tag for IEC drawings? Use your imagination... go for it!
-
Repeating In-line Wire Number Tags with Auto-update
February 11, 2007 03:56 AMby Nate HoltA neat suggestion... similar to instrumentation trace lines with embedded, repeating text to identify the line type. But in this case, the user wanted repeated wire number tags that auto-update as required. This is possible to do by hand. Use AutoCAD Electrical's in-line wire numbering and then manually placing extra wire number "copies" (with the "Copy Wire Number Inline" command) at intervals along each wire segment. These are all "smart" in that if the wire number assignment for the wire network changes, all of the inline wire numbers update as well. They even auto-stretch or compress the gap in the wire to accommodate changing wire number text string length!
But, wouldn't it be cool to create a little custom tool to pop these in automatically and avoid the tedious manual process? You would just pick on a numbered wire network... the extra in-line wire number copies would automatically pop in at fixed intervals.
BEFORE:

AFTER:

Here's a little AutoLISP utility that might do the job. It makes some calls into the AutoCAD Electrical Application Programming Interface, the "API", documented under the AutoCAD Electrical HELP system > API. Download it here and give it a try.
1. Download utility
2. APPLOAD it
3. Type WNUM_REPEAT_INLINE [Enter] at command line
4. Pick the wire segments you want to process. In they go!
Now, let's test...
Pop a fuse into one of the wires. Note that the down-stream wire numbers automatically update to the next unused wire number!

Manually edit the downstream wire number to be a longer text string. Note that the embedded wire numbers not only update but the wire gap widens to accommodate the wider string! This is all standard AutoCAD Electrical behavior.

Final Non-Caution
Don't be afraid to modify this utility to make it do other cool stuff. This can be fun!
UPDATE: oops, original version only worked on ACE2008. New version uploaded that should be okay for any version. Sorry!
-
Discrete Cross-referencing on Large Schematic Symbols
February 9, 2007 05:51 PMby Nate HoltSome users want to show a reference-only representation of each child contact on the parent symbol and position its single piece of cross-reference annotation under it or near it. They want AutoCAD Electrical to then keep each one of these discrete cross-references up-to-date.
The Desired Outcome...
In the example parent relay symbol shown below, the vertically oriented text right below each reference-only contact representation points at the sheet and line reference location of where that child contact is actually found.

... But can't do it
Out-of-the-box, AutoCAD Electrical cannot do this, that is, it is not designed to insert individual cross-reference values spread out across a large schematic parent symbol. The standard cross-referencing for a parent symbol's child contacts is going to be either comma-delimited attributed text or else presented in a table format.
AutoCAD Electrical's API to the Rescue
But where out-of-the-box features and options end, you can push the limits of AutoCAD Electrical to deal with your custom requirements. Here's one way to try to deal with the above... 1) We'll add some extra attributes to our large schematic relay symbols to display this discrete cross-reference information, and 2) We'll write a small external AutoLISP utility to process these modified symbols and update them with cross-reference information based upon child contact data pulled from the active project's scratch database.
Modified Library Symbols
Let's think about this. Let's say we have a relay coil symbol as shown above. Four contacts. Each with a unique pair of pin numbers. How can we map a child contact, let's say a contact inserted with pins 23,24, inserted on some drawing in our project, back to a parent and have it land the cross-reference annotation just below the graphics marked with pins 23 and 24?
In our solution here, we're going to try to use groups of three related attributes for each contact reference. One attribute for the actual cross-reference annotation, and two attributes to carry the pin number assignments for the target contact. The three attributes are linked together by a common substring in the attribute tag names.
Here's our schematic library symbol with the extra attributes:

Here's the linking scheme. Look at the left-hand contact. The discrete cross-reference attribute name is XR_1 and the two pin number attributes are XRT1A and XRT1B. The fourth set of attributes is XR_4 and XRT4A, XRT4B. So, our scheme is to add attributes in groups of 3 using this naming convention. Note: in this example symbol, with download link below, the pin attributes are preset with default values and the symbol has a PINLIST attribute that is preset with the pin list info (so no catalog lookup is needed to make this thing work if you want to play with it).
Our custom AutoLISP Cross-Referencing command
We write our AutoLISP utility to look for these new attributes and intrepret the groupings based upon the naming convention we've set up above. Here's our proposed cross-referencing utility to operate on these special attribute groupings. Download here.
Testing
To test: 1) Insert instances of the parent symbol (the above sample is here), 2) insert child contacts here and there and relate back to the parent symbol. 3) Qsave your drawing and maybe freshen the project database to make sure that all child contact data is in place. 4) APPLOAD the attached AutoLISP utility and type CROSSREF_DISCRETE at the command line and press [Enter].
How does this thing work?
Open up the AutoLISP file with a text editor (or in the free Visual LISP editor that is built in to AutoCAD - type VLIDE at command line). If you scan down through the short program, you'll see a number of queries on the project's scratch database file. There is a query to get all of the "parent" symbols found on the active drawing (query on COMP table), a query to get all "child" symbols from all dwgs in the project (query on the COMP table again). Then it checks each parent on the active drawing for existence of an attribute that starts with the name "XR_". If a parent has that attribute, then the utility processes that symbol. It finds all child contacts with the same tag-ID value. Then for each child it does a query on the COMPPINS table to get that child's two pin number values.
Now, with the above info, it scans the parent symbol and pushes the cross-reference annotation out to the appropriate XR_n attribute based upon the pin numbers found on the XRTnA and XRTnB attributes. Seems to work. Neat.
-
Writing to Block Attributes in un-opened Drawings - Example App
February 6, 2007 07:37 PMby Nate HoltThis little utility illustrates some interesting things you can do with the AutoCAD Electrical API. It shows 1) query of the project database, 2) a simple UI using classic DCL, and 3) writing new attribute values back to block inserts without opening the individual AutoCAD drawings.
Here's the deal
You frequently re-use previous AutoCAD Electrical designs for new projects. You run the Copy Project command to create the base new project and run the Title Block update utility to adjust the title blocks.
Wow, in a few minutes you're a week ahead of where you would have been in your pre-AcadE days. But now you run into a more tedious part of the process. You decide that you need to go through all 500+ drawings in your copied project. You need to adjust each drawing's default "IEC" Installation config value from its existing "CELL01" value to the new project's value of "CELL02". You need to do this before you can run the component re-tag across the new project set and do the final touch-up on the project drawing set.
So, is there any way around this? Yes... this little utility illustrates one way to do it.

You highlight the drawings to process in the top part of the dialog and enter in the new INST and/or LOC value in the bottom part. Hit OK and it should happen (make backup of your work first, just in case!). This should work on AcadE 2007 and above. If you want to play with this sample utility, download the AutoLISP file and the support AutoLISP dialog DCL file.
To use:
1. Download both files, put the ".dcl" file somewhere in your Acad path so the utility can find it.
2. APPLOAD the first file, project_inst_loc.lsp
3. Type PROJECT_INST_LOC [Enter] at your command line to launch the utility.
4. Pick dwgs to process and enter the new Inst/Loc values. Hit OK.
When finished, you may need to do "rebuild" on your project's database file before you see the changes show up.
How does this thing work?
Pieces of the program are shown below, but if you want to follow along in full context, open the project_inst_loc.lsp file with a text editor (or AutoCAD's built in Visual LISP editor - type "VLIDE" at command line).
Let's dissect this thing.

Above is where the utility finds the active project's scratch database file name. It dumps the file name into a variable we've called "scratch_fnam". This scratch database is actually a file in Microsoft Access format with a bunch of tables for wires, components, terminals, and such. These tables are automatically kept up-to-date by AutoCAD Electrical.
The utility does a query on the "FILETIME" table of this scratch database file. This table has pretty much all of the information we need to make this utility do its thing. Each record in this table ties in to one of the drawings defined in our project's ".wdp" file.
The program pulls out a handful of fields for each record. These include field DWGNAME (the full path/name of the drawing file), the existing IEC "inst" and "loc" values, and the WD_M_HDL field. This is key. It is the AutoCAD "handle" number of the drawing's WD_M settings block. This is the block that includes attributes IEC_INST and IEC_LOC... these are the attributes that we want to be able to examine and possible update with our utility. It will play an important role at the very end of the utility.

Now the part above goes through the record data and builds up a list of lines of text data to be displayed in the dialog's drawing selection part of the dialog. Each line carries the INST, LOC, and drawing name for each drawing, separated by "\t" TAB characters. It is just a subset of the full data we pulled from FILETIME but is kept in synch with the full set of data. This list of display data ends up in a variable we've called "dsplst".
Finding the DCL support file
Here's where we now prepare to pop open a dialog. First we have to find the support file where this dialog is defined.

These lines search in the Acad and the AutoCAD Electrical support paths for the target file. If not found then an error message will display and the program will fall out the bottom and exit back to the command prompt.
The DCL dialog definition itself

Above is the content of the dcl file for our utility. It looks a bit cryptic but compare it with the actual display shown in this posting's first image. You see the title, followed by the column labels for the list box. Next is the "list_box" entry itself. It defines the big pick list. Note that is has a flag "multiple_select" set to "true". This means that you will be able to do a multiple selection in the drawing list (instead of just picking and processing one drawing at a time). Finally we have some controls for the INST and LOC toggles and edit boxes.
Interaction between the AutoLISP program and the DCL definition

The above is probably the most difficult to decipher. The "action_tile" lines define what is to happen when each button, toggle, edit box, or display list subdialog is selected. The "mode_tile" lines preset whether a button is "fuzzed" out or enabled. The three lines starting at "start_lst" outputs our "dsplst" drawing data to the big list box on our dialog.
Summarizing the dialog part of this: the drawings we multi-select are returned as a list of index numbers in variable "picked". If we toggled the "Change" for INST, then variable "chg_i" is set and "chg_l" is set for change LOC. The actual typed-in values for the INST and LOC edit boxes are carried in variables "new_inst" and "new_loc".
Figuring out which drawings were selected for processing

First we have to convert the long string of space-delimited index values into a list of individual index values. For example, if you selected the first three drawings and the 5th drawing from the list, it would return this text string: "0 1 2 4". We need to break this up into a list of individual index values "0", "1", "2", "4".
The parallel lists: Data list pulled from FILETIME and the DCL dialog display list
Okay, now we can map the dwg entries selected in the dialog with the underlying full data pulled from the scratch database's FILETIME table. This will give us the full drawing name AND the "handle" of that drawing's WD_M block. This is the key to mapping our new attribute value(s) back to the drawing's WD_M block insert - on to attribute names IEC_INST and IEC_LOC.

Writing the new attribute value to the WD_M block insert

This finishes it up. The utility makes a few calls to open the target AutoCAD drawing file and push the attribute value out to the target block (based upon the block's "handle" value that we grabbed from the scratch database file, remember?).
Hopefully this will work for you. Give it a try. Don't be afraid to modify this if you want to try to do something more specific to your needs.
UPDATEA similar set of calls may be used to read/write Xdata values to entities on an unopened drawing file. They are twins to the "mod_attr_val" functions in the example above. Here are the "attribute" ones used in the original example above. Tried on ACE2008 and worked fine. May work on earlier versions, not sure. Make sure that wdcom1b.fas is APPLOADED.
(wd_1b_mod_attr_val ff ben atnam atval firstonly updflg) ; write attribute value "atval" out to block insert entity handle "ben" to attribute name "atnam"
and here is the twin that does Xdata
(wd_1b_mod_1000_xdata ff hdl appnam data updflg) ; create or update xdata appname "appnam" with value "data" on entity with handle "hdl" on the target drawing
... and the read xdata version
(wd_1b_get_1000_xdata ff hdl appnam) ; returns "appnam" xdata value pulled from entity "hdl"
-
AutoCAD Electrical's Modify Symbol Lib util - Pushing it beyond its limits
February 5, 2007 08:51 PMby Nate HoltThe AutoCAD Electrical "Discussion Group" http://discussion.autodesk.com/index2.jspa?categoryID=13 had a recent posting about the "Modify Symbol Library" utility. This user needed to go through the many hundreds of schematic library symbols (thousands?) and find those with vertical rotated terminal pin attribute text (highlighted in YELLOW below).
BEFORE:

For each one found, he wanted to rotate the attribute text back to horizontal, resize the text, change its justification to "Left", and then reposition the attribute to the opposite side of the wire connection attribute (wite connection attribute shown in GREEN below).
AFTER:

This task seems more or less in line with what the utility was meant to do... but not totally. There are no pre-defined options in the utility to do the rotate part and the reposition operation. But, the user correctly surmised that a small AutoLISP function called from this utility might fill in the gap, pushing it beyond its out-of-the-box limits.
How to do it
Here's one way to do it. This bare-bones AutoLISP utility View or Download can be piggy-backed on top of the Modify Symbol Library utility to do all three operations on each library symbol in the target library folder.
Preliminaries
Flip your system to "single document mode" (with just one drawing open on your screen, type SDI at the command line and change the value to 1). Download, modify (if required), and then APPLOAD the utility.
Here we go!
Now launch the Modify Symbol Library utility from the Component pull-down menu.

Select the symbol library path on the next dialog. Then the utility's main dialog appears (below). Enter the AutoLISP function's command name in the edit box as shown, enter this: (c:termxx_rotate)
It corresponds to the "(defun...) defined in the AutoLISP text file.

Hit the utility's "Start" button to fire it off. Then go get a cup of coffee. When you come back, it should be nearly finished.
-
Linking AutoCAD Custom Drawing Props back to AcadE Proj Mgr
February 2, 2007 05:56 PMby Nate HoltThis one was a head-scratcher. A reseller wanted to know if it was possible to push values set in AutoCAD "Custom drawing properties" back into AutoCAD Electrical's project manager. Right now, the AcadE project manager will populate the AutoCAD custom drawing properties but not vice versa.
The current state - Limited to just one-way update
Here's the current state. In AutoCAD Electrical's project manager I right-click on a drawing entry and select the drawing properties options...

... and up pops the normal AutoCAD Electrical Drawing Properties dialog (for the active drawing). Changes I then make here get written back to the active drawing's settings block (the invisible WD_M block insert) or to the project definition file (the.wdp file).

But this action also triggers the AcadE Project Manager to push a copy of these values out to the AutoCAD custom drawing properties.
If I then launch the "Drawing Properties" from the generic AutoCAD "Files" pull-down menu, I can see that these values are now present and displayed in the drawing's custom properties (shown below).

How can we push values back the other way?
Thanks to Autodesk's Mike Sptizer for pointing out an AutoLISP approach. This uses a handful of "vla" calls from the Visual Lisp extensions to AutoLisp. The key part of the utility's code is shown here:

You can download a full copy here. Appload it and give it a shot. Edit some values in the AutoCAD "Drawing Properties" dialog, then test by typing dwg_props_2_acade [Enter] and see if the AcadE-specific ones get pushed back into the AcadE drawing manager and the WD_M block on the active drawing.
Don't hesitate to customize this example utility to meet your specific needs!
-
When one Tag-ID isn't enough
February 2, 2007 12:12 AMby Nate HoltLet's say that you design coordinated drive systems. You've built up a nice big schematic library symbol for the variable speed drive itself but it's so big and busy that it makes it hard to find its tag-ID text. Plus, you really need to have the tag-ID show up a couple more times on the symbol. Not just for the main tag-ID but a few more strategically placed on the drawing. You'd like a piece of attribute text that you can move to the bottom of the drawing as a label for DIP-switch settings. Maybe another one that you can position near a power setting jumper detail.
But most important thing you want is this, you want all three of these attribute text values to update together when you first pop in the symbol and also, later on, if you edit the tag-ID or if you re-tag your project drawing set.
Not a problem. Several approaches, one would be to create some dummy "child" components.
The COPYTAG Method
But here's a cool alternative... add a couple COPYTAG attributes to your symbol and, bingo, you're good to go. Here's how it works...
Let's just use this simple example symbol below. It's a "parent" symbol because it carries the AutoCAD Electrical attribute TAG1. It carries other normal attributes for wire connections, descriptions, terminal pins, and ratings to be pulled into various reports.

But it has two extra attributes at the bottom... COPYTAG01 and COPYTAG02. These are the extra ones we've added to carry a copy of the assignment that ends up on the main tag-ID attribute TAG1. When AutoCAD Electrical pushes a value out to the TAG1 attribute, it will also update any COPYTAG* attributes it also finds on the symbol.
The %T Parameter
But wait, there's more... note the strange parameter held in the "Prompt" field of each attribute definition:


You can define a character string of text to output to the attribute. The calculated tag-ID will pop in at the point where you've embedded the %T parameter.
So, here's our symbol just after AcadE inserts it into a drawing:

The COPYTAG* attributes will follow the main tag-ID at the top. Now just grip each one (or use AcadE's move attribute tool) and move down to the bottom of your drawing, just above the dip switch and power settings info. Again, they'll auto-update, no matter where you move them to on your schematic. Pretty neat. If you don't want any extra text with the copies, just leave the "Prompt" attribute definition value blank.