-
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.
-
Circuit Generation by Layer Combos - AutoCAD Electrical
May 21, 2008 11:53 PMby Nate HoltCreating custom circuit designs by exposing/hiding combinations of layered sub-circuit options!
You have a standard design but with many options. You draw each option on its own layer and save the whole thing as a template drawing. Then, you create a desired design by copying the template and turning on (or off) a specific set of option layers.
There are a couple problems with this approach and AutoCAD Electrical, but they can be overcome (!).
First of all, AutoCAD Electrical will include all components marked with catalog information in its BOM reporting, even components on a layer that has been frozen or turned off. So, for options that you do not want in your final design, the components and wiring on those layers need to actually be deleted from the drawing (not just frozen or layer turned off).
Second, AutoCAD Electrical interprets line entities to be wires only when those line entities are found on one of the user-defined layers specifically set aside for wiring. The layer name itself gives the wire's color and gauge value and perhaps insulation type. So, pushing a couple components and interconnected wiring out to an "option" layer will defeat the ability of the line wire to retain its wire layer name assignment.
This second issue, pushing wiring out to a specific option layer but providing a means to restore the original wire layer names if the option is "selected", is tricky. But a solution is to save the original layer name as an invisible "Xdata" value right on each wire segment as it is pushed to its option layer.
The attached autolisp file contains a set of "tools" to make this all possible. Here is a listing of the five small functions contained in this file:
files/21401_21500/21481/file_21481.lsp (download this file and rename PushPullLay.lsp)
(APPLOAD the PushPullLay.lsp file. Then each function below can be typed in at the command line prompt.)
PushToLay [Enter] - prompts you for a new "option" layer name. Then prompts you to pick wires and components that are to be associated with that option. The utility moves the picked items to the target option layer. The original layer names are saved on each moved component as an Xdata value to be used by PullFromLay or (pull_lay <layerlist>) functions below. You would use this tool to help create the original circuit "template" drawing with all of its various option layers.
PullFromLay [Enter] - prompts you for an existing "option" layer name. Then it pulls all components and wiring found on that layer (layer can be frozen or OFF, no problem) and restores the wires and components to their original layer assignments (saved when originally set up by PushToLay above).
EraseLay [Enter] - prompts you to enter an unused "option" layer that you want to remove from the active drawing (i.e. so that it will not show up in the BOM report).
These next two functions might be useful encoded into an overall VB, VBA, or AutoLISP application to auto-generate your circuit designs:
(pull_lay <layerlist) - same as PullFromLay above but the layer name or names are passed as a list. For example, let's say you want to restore layers "OPTION3" and "OPTION55" with one call and no user prompts. You would set up your VBA or AutoLISP application to make this call: (pull_lay (list "OPTION3" "OPTION55"))
(erase_lay <layerlist) - same as EraseLay above but the layer name or names are passed as a list. For example, erase everything on OPTION4: (erase_lay (list "OPTION4"))
How it works
Here is the "PushToLay" function. It prompts you for the targer "option" layer name. Then you select the components and wiring that is to make up this option. The utility process each entity in the selection set. It saves the existing layer name on the entity as a "PUSH2LAY" Xdata value. Then it pushes the entity to the target layer.

The PullFromLay utility pretty much works in reverse. It prompts you for the option layer name. The utility then creates a selection set of everything it finds on that layer. Then it processes each of these entities, reads the save layer name from the PUSH2LAY Xdata value. It restores the entity to that layer. Presto... the option suddenly appears, neatly wired up and everything displayed on the appropriate layers!
-
Concatenations in Title Block Update - AutoCAD Electrical
May 2, 2008 08:31 AMby Nate HoltGoing beyond simple one-for-one text value insertions into a title block... this customer issue came up a couple days ago. AutoCAD Electrical's project-wide title-block update tool defaults to simple mapping of discrete drawing or project setting values to individual attributes in the title block. But this customer needed to format several of these drawing-specific values into one concatenated text string value and push it out to a single attribute on each drawing's title block.
Let's say that the user's title block carries attribute "TB-DNAM" that is to carry a value that is a combination of the following project and drawing-specific values: Project "LINE3" value, then a dash character, then the project's "LINE14" value, then a colon, and finally the drawing's SHEET number assignment.
Normally, this would have to be all done by hand. But with a little customization, we can trigger AutoCAD Electrical's title block update command to do this attribute value format automatically. Let's write a little AutoLISP function that we'll call "tb_concatenate.lsp", and it will concatenate values and return a single text string.
And then, in our title block update ".wdt" file (or on the title block's invisible WD_TB attribute), we'll include the "TB-DNAM" attribute annotation to reference this AutoLISP function like this:
TB-DNAM = (tb_concatenate (list 3 "-" 14 ":" "SHEET"))
The key is that our function will accept a list of parameters to concatenate. So, it is "general purpose" !
Here is the tb_concatenate utility and a brief summary of how it works.

Above and toward the end, the function first reads in data from the active project's ".wdp" file. This will carry two lists of data that may be needed. First, there is the list of all project "description" lines, the LINE1 through LINEx values defined for the overall project. And second, there is a list of drawing-specific Section, Subsection, and drawing description lines. Each entry in this list is for a drawing in the project. Each entry is a "sublist" containing a list of the drawing's values.
Now, below, the function begins to process the list of parameters passed in the call. The parameters are in "linelst" and processed one at a time, the "foreach" call. Each is checked to see if it is an integer number or a text string. If integer number, then it looks into the project description list pulled in above. If not integer, then it compares the passed text string parameter against a set of specific flags like "SHEET", "IEC_L", and "DD2".

If no match as integer numer or on any of the specific text flags, it finally (near the bottom below) assumes that the parameter is just a text string to insert directly into the output.

And that's it. When finished processing all of the passed parameters, the full concatenated string is returned by this AutoLISP expression. The AutoCAD Electrical Title Block update command pushes this concatenated value out to the target attribute on the title block ( ! ).
Download utility here:
files/21401_21500/21413/file_21413.lsp - download and rename tb_concatenate.lsp
To use, you MUST first APPLOAD this utility before launching the title block update command. If you are running in multi-document mode (the AutoCAD default), then you'll need to use a method to make sure this utility loads with each drawing as it opens. Otherwise it will work on the first drawing and then fail from that point forward.