Controlling the Machine

  • 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

  • Titleblock Update - Previous / Next Sheet Numbers - AutoCAD Electrical
    April 13, 2007 05:16 AMby Nate Holt

    One of the lower-tech tasks that AutoCAD Electrical can do so well is title block update of a project drawing set. You map data like project name, sheet number, drawn by, and so on to various attributes carried on your standard drawing title block. You can set up this mapping either internally on the title block itself (using an invisible WD_TB attribute) or through an external ".wdt" mapping text file. Both methods are outlined in the AutoCAD Electrical on-line help.

    Taking it to the next level

    But here's the rub. Maybe you want to do something a bit more sophisticated than just map project and drawing values to the title block. For example, let's say you not only want to show the drawing's assigned SHEET number, but you also want the title block to include the previous and next drawing's SHEET number assignments.

    This close-up of the title block is for sheet number "14". But you can tell that the drawing immediately preceding this drawing and the next drawing after it have been assigned sheet numbers 8 and 15 respectively. You want the title block update to be "smart enough" to go to the previous and next drawings in the project sequence and pull out some info to put on to the current drawing's title block.

    tbnp01.PNG

    So, how can we get AutoCAD Electrical to figure these out and map the values to attributes on the current drawing's title block? The key is in the mapping. AutoCAD Electrical allows us to embed an AutoLisp expression in our mapping file and link it to a title block attribute. The returned value from this expression gets inserted as a text value on to the target attribute.

    Here's how we can do this

    First we make sure that our title block has the extra target attributes. The exploded title block is shown below. We've set up attribute name "PREV" for the previous drawing's sheet number and "NEXT" for the next drawing's sheet number. Simple enough so far.

    tbnp02.png

    AutoLisp functions called from Title Block mapping

    Here's the fun part. We create a small AutoLisp function to pull out the "previous" drawing's SHEET value and a second lisp routine to pull out the "next" drawing's SHEET value. Here's the "next" sheet number function shown below (the "previous" function is identical except the index is decremented instead of incremented).

    tbnp05.png

    AutoCAD Electrical maintains a global variable GBL_wd_prj_ixlst that carries a "list of lists" of various data for the drawings defined in the active project. One of these lists is a list of SHEET number assignments for all the drawings in the project. This is what each Lisp utility will access to find the "previous" and "next" drawing sheet number assignments.

    Setting this up in your title block attribute mapping
    Here's a little bit of what the ".wdt" file might look like. The left-hand side is the target attribute name, the right-hand side is "what" gets written to that attribute.

    tbnp06.png

    The above in RED is what the set of two entries would look like in a title block ".wdt" attribute mapping file. If you use the self-contained WD_TB attribute method, the encoded strings would look pretty much the same (except semi-colon delimited - see the on-line help).

    Running it

    Download the lisp file here and copy it to a folder that is somewhere in your ACAD search path.

    Select the Project Utilities option from the project manager or from the pull-down menu or project toolbar fly-out.

    tbnp03.png



    Toggle the "Update Title Block" option and make selections on the detailed sub-dialog that appears.

    tbnp04.png


    Select the drawings to process and hit OK. That should do it. Each drawing should get the previous and next sheet number assignments included in the title block.

    1 Comment | Add CommentIn Controlling the Machine > All

Previous Post

  • Autodesk Labs - new blog
    April 13, 2007 01:15 AMby Nate Holt

    Please visit and bookmark the new Autodesk Labs blog hosted by Scott Sheppard. It goes by the name "It's Alive in the Lab" (a la Dr. Frankenstein) and is the home for new prototypes, experiments, applications, and technologies. Check it out...!

    1 Comment | Add CommentIn Controlling the Machine > All

  • Tracing Polyline-connected Components - AutoCAD Electrical
    April 11, 2007 02:58 AMby Nate Holt

    This may not be such a great idea... but someone recently asked a question about trying to use AutoCAD Electrical to design PCB's. The answer is "No." It's not set up to do this. Yes, you could do BOM with no problem. But, for component connection and from/to extraction, you'd probably want to use polylines for the traces. AutoCAD Electrical is NOT set up to process point-to-point polyline traces... it is set up to process wire networks consisting of line segments.

    But, Just for grins...

    Okay, just for fun, let's say you're really desperate. You really want to use AutoCAD Electrical for just a very minimal implementation of this polyline thing. What you can do is use AutoCAD Electrical's "Application Programming Interface" API to create a crude From/To report generator that will process components interconnected with polyline traces.

    Normal AutoCAD Electrical Components BUT using Polyline Connections

    Here's a simple example. The components are normal AutoCAD Electrical symbols with the TAG1 and RATING1 attributes, terminal attributes, and invisible wire connection attributes, and so on. The traces are POLYLINEs drawn right up to the wire connection point attributes. That's it.

    pcb02.png



    From/To Extraction Program

    Here are parts of the simple AutoLisp utility that will process this type of drawing and give a rudimentary from/to report (download the whole thing here). The "key" call in this progam is the API function that returns wire connection point data. It is the (c:wd_get_sym_pntlst...) call shown about half-way down in the code snippet below. For each block insert in the drawing, it makes a call to this API function to return the list of data for all of the component's wire connection points. Then it cycles through each point, throws a small "crossing window" around its XY coordinate, and tries to capture a connected polyline. If one or more are found, it saves them in the "p_data" list for processing later.

    pcb04.png

    Now it has a big "p_data" list of all component connections that appear to tie to a polyline. The final step is to start through this list and find the two end connections on a per polyline basis (i.e. hopefully there are two connections in the list for each polyline found in the drawing). This is done by looking for a match on a common saved "handle" of the polyline entity. For each connection match on a given polyline's handle, the component's tag-ID, terminal pin attribute value, and a few other pieces of data are extracted with a few more API calls.

    pcb05.png

    Now, with component data found at each end of the polyline trace, the from/to entry is written out to the report in comma-delimited text format (not shown here, see full program). The program loops around until all polylines have been accounted for.


    Sample Report Output

    That's it. It more or less works. Here's the resulting report (called up in Excel):

    pcb03.png

    1. Download the attached pcb_trace.lsp file
    2. APPLOAD and reference the lsp file
    3. Type PCB_TRACE [Enter] at your command line




    0 Comment | Add CommentIn Controlling the Machine > All

  • Recovering Corrupted Wiring in AutoCAD Electrical
    April 5, 2007 03:50 AMby Nate Holt

    AutoCAD Electrical is pretty forgiving when it comes to using regular AutoCAD or AutoCAD/LT to edit the "smart" schematics. When you pass your design to the customer who does not have AutoCAD Electrical installed, he can (fairly) safely edit components with any attribute editing command, can copy components and use LINE entities for new wiring (as long as the lines are on a "wire layer"), and so on. But there is one area that is pretty risky... using regular AutoCAD's COPY command for copying wiring and wire numbers.

    The reason is that there are invisible "Xdata" pointers carried on wire line segments. These point to the wire network's wire number block insert. The pointer's value uses the wire number block insert's "handle" number. So, each wire segment in a numbered wire network will carry a single Xdata pointer back to that network's wire number block insert.

    Misuse of AutoCAD COPY command

    Now, here's where the problem shows up... Copying wiring that already has these wire number Xdata pointers will trigger those copied wires to point back at the original "uncopied" wire number. This happens even if a copy of the wire number block insert is included in the copied entity selection set.

    Is there any recovery other than erasing this stuff and re-inserting using AutoCAD Electrical? There may be an option.

    Here's a little utility that may be able to restore the pointer relationship for copied wiring. You APPLOAD this tool and then type RESTORE_WNUM [Enter] at the command line. Pick pairs consisting of one copied wire number and one copied wire segment that the copied wire number is supposed to go with. See if this works for you.

    A full listing of the AutoLISP utility is show below, and you can download a full working copy here.

    How it works


    The utility prompts you to select a line wire entity and a wire number block insert that should tie in to that line segment. The block selection is filtered on the block naming convention for wire numbers, "WD_WN*". If the selection includes a LINE with a wire number Xdata pointer value (Xdata appname is "VIA_WD_WNPTR") and a wire number block insert, then it compares the Xdata pointer value with the block insert's handle number. On a match, all is well.

    But, if mismatch, then the utility extracts a list of all wire segments in the network. It goes through and updates each wire segment's Xdata pointer to point at the copied wire number block insert.


    restore01.png




    0 Comment | Add CommentIn Controlling the Machine > All

  • Making the Part Number fit the Relay Contacts used - AutoCAD Electrical
    April 2, 2007 02:08 PMby Nate Holt

    This user-request makes sense... he inserts the parent relay coil symbol and assigns the desired manufacturer code. But does not make a specific catalog number assignment until after the design is nearly complete. At this point he wants to go back to each relay coil symbol and make a catalog assignment selection based upon the EXACT number of that relay's contacts that he actually used in the design.

    Makes sense. But AutoCAD Electrical is currently not set up to automatically figure this out "after-the-fact". It would need to gather up a list of all of the relay's child contacts (it knows this already), go through the PINLIST table in the catalog lookup database file to find all wild-card entries that match this number of NO/NC/Form-C contact combination (it has access to this PINLIST data), then go through the relay catalog lookup table (it has access to this too) and find all catalog numbers of the target MFG that match any of the wild-card PINLIST values that have the exact number/type of needed contacts.

    So, the bottom line is this: AutoCAD Electrical has the various parts and pieces of data needed to do it, but this option is just not current programmed into the product.

    Extending AutoCAD Electrical through its API

    Okay, let's try to rough out some AutoLISP code to try to make this happen! Some snippets of the overall program are shown below (this utility was quickly assembled from parts and pieces of other utilities, so some stuff may not be used).

    Here's where we prompt the user to pick on the parent coil. The utility gathers up the TAG1 attribute value, the symbol's "handle", and the INST and LOC attribute values in case we're in IEC-tag mode. A call to messy function "xref_get_data" (in the AutoLISP utilty but not shown here) does a query on the project's scratch database to find information on all of our picked parent's child contacts. Then the utility adds them up to get counts of NO, NC, and Form-C contacts used.

    cat4_combo_05.png



    Next: Collecting a list of PINLIST wild-card matches

    cat4_combo_02.png



    Next: Collecting a list of catalog part number matches

    cat4_combo_04.png



    Finally: Displaying in the dialog pick list

    cat4_combo_03.png



    Testing this Utility

    Download the AutoLISP file here and the companion dialog DCL file here. Make sure you put the DCL file somewhere in the ACAD path.

    1. APPLOAD the AutoLISP file
    2. Type CAT4_COMBO [Enter] at command line

    Here it is!

    Here we've picked on a relay coil symbol that has four child contacts used through the project drawing set. There are three N.O. contacts and one N.C. contact used. Note that the listing shows the 3NO/1NC combos plus 4NO "convertible" entries as well!

    cat4_combo_01.png

    Go for it !

    This utility is really rough. Don't hesistate to experiment with it and make it better...!


    0 Comment | Add CommentIn Controlling the Machine > All

Subscribe to Blog

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

RSS

Categories

All

Blog Roll

AUTODESK MANUFACTURING COMMUNITY

Ellipsis
The official Autodesk Manufacturing Tech Evangelist blog
Under The Hood
Brian Schanen on Vault, Productstream, and more
In the Machine
Garin Gardiner hosts the official blog of the Inventor Product Team
Controlling the Machine
Archive of Nate Holt's AutoCAD Electrical posts

RECOMMENDED

Being Inventive
The official support blog for the Autodesk Inventor product line
Between the Lines
Shaan Hurley's AutoCAD Blog
It's Alive in the Lab
Scott Shepherd's Lab's Blog
Beyond the Paper
Volker Joseph's DWF Blog
Lynn Allen's Blog
Staying current with AutoCAD and Autodesk

PEER

AutoCAD Electrical Etcetera
Nate Holt shares AutoCAD Electrical tips and tricks.
Autodesk Manufacturing Northern European
The official blog for the Autodesk Northern Europe Manufacturing Technical Team.
Sean Dotson's Site
Sean Dotson's mCAD Tutorials, Forums, Admins & more
The Autodesk Informer
Helpful sites, tutorials, and industry news
CAD Professor
Inventor, Inventor LT, and AutoCAD news and updates.

Send to a Peer

You must login to share pages.

Feedback

Tell us what you think of the site.

Send Feedback