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

  • Special PLC Address-based Wire Numbers
    July 31, 2006 02:33 PMby Nate Holt

    This came up recently... a user had a need to generate special wire numbers based upon connected component information found at each end of the wire if one end of the wire tied to a PLC I/O module.


    milnum_plc.jpg

    The wire number assignment needs to be built up from the following: the PLC modules tag-ID plus the I/O point's address plus the tag and pin number of the component at the other end of the wire.

    The AutoCAD Electrical Help --> API documentation includes a sample AutoLisp utlity that that comes pretty close to doing this as a post-processing task (i.e. run the utility and pick on the wires!). It is listed as milnum.lsp under the documentation for "wd_get_wire_netlst" in Section C. But here's the problem: instead of formatting the PLC's I/O address into the wire number, this utility formats the PLC's wire connection pin number into the wire number.

    So, it sounds like a minor adjustment to this sample utility is in order. We'll modify it to work normally, finding the connected component's wire connection pin number, but add one more check. If the component's block name begins with "PLCIO..." then we'll try to find a "TAGAxx" address attribute that matches the wire connection pin's attribute. If found, we substitute the PLC I/O address for the pin number and then build up and insert the full wire number.

    The modified version is shown here, changed in two places between the "New stuff starts here/ ends here" comment lines.

    milnum_plc02x.jpg


    It seems to work. Just APPLOAD it, run, and pick the wires. If you want to play with this and don't want to manually edit your version of the file, download it here.

    UPDATE: uploaded a bit better version: 1) tries to put left/upper component tag as prefix and right/lower tag as suffix, 2) attempts to follow a wire connection that jumps to another drawing.


    1 Comment | Add CommentIn Controlling the Machine > All

Previous Post

  • Nate's Simple AutoLisp - Lesson 002
    July 29, 2006 10:39 PMby Nate Holt

    Warning/Disclaimer: I'm neither a teacher nor am I versed in the theory behind AutoLisp programming. But I invite you to come along for a ride. This stuff is not only fun, but it can be useful ! Each lesson should take 5-10 minutes.

    So, here we go...

    Lesson 002 - First peek at Block Inserts

    AutoCAD Electrical makes heavy use of standard AutoCAD blocks with attributes. There is a lot of neat stuff here, so let's get started.

    Just so we can stick together, download this sample drawing here and open it up. Its file name is lesson_002.dwg.

    Let's go back to where we left off in the last lesson. We were picking a LINE entity with entsel and opening it up with entget to examine its internals. Let's enter the same AutoLisp expression as before but this time let's pick on a block insert entity instead of a line entity.

    1. At the Command: prompt type this... (entget (car (entsel))) [Enter]
    2. Pick on the limit switch symbol LS406 in the upper left-hand part of the drawing. Now you'll see a bunch of data displayed in your command window. It will look something like this:

    nate_lesson002a.jpg

    This is a list of sublists of data defining the base part of the block insert. Each element of this list starts with a group code number followed by the value for that group code.

    Group code 0 gives the entity type. Find this entry: (0 . "INSERT") in the data returned. This tells us that we picked and opened a block Insert instance.

    Group code 8 identifies the base layer that this block instance is inserted on. In the example here it is layer "SYMS".

    Group code 2 gives the block name, "HLS11".

    Group code 10 for an INSERT entity gives the block's insertion X,Y,Z coordinate. For our picked instance of "HLS11" the returned data says that it is inserted at XY coordinate 3.875,16.0.

    Group codes 41-43 give the block insert's X,Y,Z scale factor values and 50 gives the rotation angle.

    Let's figure out how to write a single-line AutoLisp expression to just give us the block name of the picked entity. Somehow we have to extract the group code 2 value from this big list of data.

    There is a base AutoLisp function called assoc that can be of great help to us here. We can pass the group code number we want and the full list of data to search. The assoc function will return just the part of the list that matches the specific group code we pass to the assoc function. Let's try it. We want to get the insert's block name, this is carried in group code 2:

    3. Type this at the AutoCAD Command: prompt.... (assoc 2 (entget (car (entsel)))) [Enter] and pick on the limit switch block insert. You will see this returned to the command line prompt:

    nate_lesson002b.jpg

    Hmm... we're close. But we need to get rid of the first part of this list and just leave the block name. There is another AutoLisp function, (cdr .... ) that discards the first element of a list. Let's try it.

    4. Type this at the Command: prompt... (cdr (assoc 2 (entget (car (entsel))))) [Enter]. Make sure you end with five ")" to keep the "(" and ")" counts balanced. Pick on the limit switch again. Now we get a nice clean return.

    nate_lesson002c.jpg

    Okay, time's up. Next lesson we'll eliminate the need to type in this AutoLisp expression into the command line every time we want to run this "program". We'll create a text file version of this program and learn how to "APPLOAD" it. This will let us quickly run it whenever we want.


    0 Comment | Add CommentIn Controlling the Machine > All

  • Nate's Simple AutoLisp - Lesson 001
    July 29, 2006 05:05 PMby Nate Holt

    Warning/Disclaimer: I'm neither a teacher nor am I versed in the theory behind AutoLisp programming. But I invite you to come along for a ride. This stuff is not only fun, but it can be useful ! Each lesson should take 5-10 minutes.

    So, here we go...

    Lesson 001 - Picking stuff

    We'll start out simple, nothing fancy. We'll just type and run AutoLisp expressions right at your AutoCAD "Command:" line prompt.

    1. Open up an AutoCAD drawing. Draw a LINE entity anywhere.
    2. At the Command: prompt type this... (entsel) [Enter]

    nate_lesson_001a.jpg

    3. As soon as you hit the [Enter] key, AutoCAD evaluates what you've typed on the command line. The word "entsel" inside of the open and close parenthesis is a predefined AutoLisp function for picking stuff, one thing at a time. It defaults to a "Select object:" prompt. Now pick on the LINE entity in your drawing.

    You will see something like this displayed on your command line:

    nate_lesson001b.jpg

    It is a "list" of two pieces of data. Only the first element is of interest to us now. It's a numeric code that gives the entity name identifier of the LINE entity you selected.

    Okay, let's dig a bit deeper.

    We need to isolate this entity name from the two-element list returned by (entsel).

    4. Type this at the command line prompt: (car (entsel)) [Enter]
    5. Pick on a line entity. Now you'll see the entity name code all by itself. The "(car ... )" AutoLisp function returns the first element of a multi-element list.

    nate_lesson001c.jpg

    Now, the cool part. We're going to "open" up and display the guts of a picked entity.

    6. Type this at the command line prompt: (entget (car (entsel))) [Enter]
    7. Pick on a line entity. Now you'll see a bunch of data displayed in your command window. It will look something like this:

    nate_lesson001d.jpg

    At first it just looks like gibberish. But there is some interesting stuff in here. Let's poke around.

    This is the basic data about our picked LINE entity. It is a "list" of stuff. Each element of this list starts with a group code number followed by the value for that group code.

    Group code 0 give the entity type. Look at the data and pick it out. You'll see (0 . "LINE"). So, we picked on a LINE entity.

    For a LINE entity, group code 10 gives the line's staring X,Y,Z coordinate. Look for the (10 ....) entry in the data dump. The data following the 10 is the starting X,Y,Z coordinate. Group code 11 gives the ending X,Y,Z coordinate.

    Group code 8 gives the layer name that the entity is inserted on.

    Okay, that's all for now. Time's up. Hope to see you for the next lesson!




    0 Comment | Add CommentIn Controlling the Machine > All

  • Why does Thunder thunder longer than lightning lights?
    July 27, 2006 06:09 AMby Nate Holt

    I think a recent lightning strike took out my home air conditioning system. The repairman will be here tomorrow. I pretty much have to replace the whole system due to the need to flip over to the new ozone-friendly refrigerant. Talking $$$.

    Of course this triggers some thinking about lightning. For example, a lightning stroke lasts just a split second, the whole thing stretching a couple miles up into the sky. The superheated air around the lightning stroke "explodes" and causes a sound spike, i.e. thunder.

    So, if this thing lasts a split second, why doesn't thunder just last a split second. I know, I know, in school they said it was just echoing off of hills, trees, buildings and stuff. But I don't buy it. Here's what I think (see crude AutoCAD drawing below... hey, I'm electrical, I can draw the lightning okay but that's about it):

    lightning.jpg

    This sketch shows me standing a mile away from a 2.5 mile long lightning stroke. Flash! ... wait 5 seconds, and I hear thunder (speed of sound is about 5 seconds per mile). But I don't here "all" of the thunder right away. I just hear the part of it that was the closest to me, segments A and B. Both segments are about the same distance from my ear so this part generates a big, sudden "boom". Then, over the next 2.5 seconds, the sound made by the lightning along segment C reaches my ear. Then, a second "boom" as the thunder created along the whole length of segment D reaches my ear at about the same time. And to finish it off, the thunder created by segments E and F reach my ear over the final 5 seconds of the thunder's life.

    Does this make sense? It seems more logical than the "echo off of buildings and trees and stuff" theory.




    1 Comment | Add CommentIn Controlling the Machine > All

  • A couple SS->PLC I/O Tricks
    July 26, 2006 02:51 PMby Nate Holt

    Here are a few tricks/tips that might be useful with the Spreadsheet --> PLC I/O generator utility.

    1. Pin number assignments to terminal symbols. You can define the terminal symbol block name and the tag for the terminal but there's no obvious way to also define the terminal's pin number assignment. Try this... in the terminal's tag field, add a "colon" and then the pin number. The utility will see the colon as a delimiter in the field and insert what follows it into the terminal's TERM01 attribute. This gives you the pin number in your drawing. For example, let's say the terminal's tag name is to be TB1 and its pin number assignment to be "1A". Enter the colon delimiter and the "1A" suffix as shown here.

    plctrick01.jpg

    2. Pin number assignments to component symbols. Let's say you want to insert a pushbutton symbol but also want to annotate the pins as "21" and "22". There are no columns in the spreadsheet for pin numbers. But you can concatenate extra attribute assignments into any field of the in-line device using a ";" semicolon delimiter. In the example shown below, the normal LOC attribute is "FIELD" but we've forced two more attribute definitions into this one field. The component's TERM01 attribute is to be assigned a value of "21" and TERM02 a value of "22".

    plctrick02.jpg

    UPDATE: the attributes you manually add with the semicolon delimiters are not limited to pin number attributes.

    2 Comments | Add CommentIn Controlling the Machine > All

  • Migrating PLC point descriptions back to overall module representation
    July 16, 2006 01:38 AMby Nate Holt

    This one might appeal to 1% (or less) of the audience, but I'm posting it because it was a challenge and, more than that, it was flat-out fun to do. Here's the deal... user wants to insert a bunch of single I/O points throughout the design and, when finished, insert a full version of the module on some master drawing. No problem so far. User then wants to have some kind of cross-reference data on this master drawing (next to the module) to show where all the individual I/O point symbols are located throughout the drawing set. Again, no problem (can use the "Cross-reference table" under the "Components" > "Cross-Reference" pull-down menu or use the PLC I/O Address/Descriptions report and insert as a table).

    BUT, here's the rub. The user wants the 3-5 lines of description text assigned on the individual I/O points inserted throughout the drawing set to back-annotate to this overall module. Each single I/O point's description attributes need to find the right module and the right I/O point on that module. That's where we run into trouble.

    Example of what is desired is shown here.
    plc_desc_crossref.jpg

    Solution: Make the overall module just a simple, stripped down version of an AutoCAD Electrical PLC I/O module. It is inserted into the drawing (example stripped-down PLC I/O symbol with necessary attributes here) using the normal Insert Component command (ex: enter the block's name in the "Type it" edit box). Enter the starting address for the module.

    So far, so good. But the description text for each I/O point starts out blank. We need to suck these all in from the individual I/O points inserted throughout the drawing set (just the ones that point back at this particular module via TAG-id and I/O address values).

    So, how do we get this data (shown on the right) pulled in and matched up with the module tag and I/O addresses? Write a little AutoLisp utility, that's how. Example utility can be downloaded here. It prompts the user to pick a module to update. It then queries the project's "scratch database" file, finds all the related single I/O points, and pulls the descriptions and cross-ref locations over to the main module.

    APPLOAD it and then try it (type PLC_DESC_CROSSREF at the command line and pick on the overall module). It seems to work. Don't be afraid to modify the utility to suit your specific needs. It can be fun...!

    UPDATE: a reader suggested an improvement... blank out the old cross-reference text before writing the new text back out. This made good sense and a revised version of the utility is in place.



    1 Comment | Add CommentIn Controlling the Machine > All

  • Dual Catalog Lookup: Preferred and Everything else
    July 12, 2006 04:46 AMby Nate Holt

    A curse of "lots of catalog content" is that it can be hard to quickly find and select the common everyday stuff you use. Wouldn't it be nice to just have common stuff show up in the catalog lookup dialog? Then, if you need some rarely used part number, you could switch over to the "full" version of the catalog lookup database?

    One way to make this happen is to implement AutoCAD Electrical's dual-file catalog lookup.

    Create a stripped-down version of default_cat.mdb with just the standard stuff you most often use. Keep its name as "default_cat.mdb" while renaming a copy of the original full version of this file to some other name, let's say "everything_else_cat.mdb".

    Now for each project, go to Project Properties --> Project Settings --> Catalog Lookup File Preference --> Other File --> and select the "everything_else_cat.mdb" as the "Secondary catalog lookup file for this project".

    secondary_cat01.jpg

    That should do it.

    For each project where you've set this up, you will now only see the standard stuff presented in the initial catalog lookup dialog. But if you need something that is non-standard (not listed in the stripped-down default_cat.mdb), then you just pick on the catalog lookup dialog's "Other" button. The catalog lookup dialog temporarily switches over to the secondary catalog lookup file (i.e. the "full" one with everything) and there you are!

    0 Comment | Add CommentIn Controlling the Machine > All

  • Mirror Tears
    July 10, 2006 03:18 PMby Nate Holt

    This just came up... a user inserted some hydraulic schematic symbols but wanted the graphics to show mirrored from how the default library symbol was constructed. Using the AutoCAD MIRROR command appeared to work but then the insert "wire" (i.e. tube or pipe) connections to the mirrored symbols started to act totally whacked out.

    The problem with using MIRROR on these schematic symbols is that it ends up reversing the symbol's "connection" coding that is embedded in the connection attribute names (i.e. the 2nd character of the "X?TERMxx" wire connection attributes).

    Solution: use the new (ACE 2007) "Reverse/Flip Component" command instead of the generic AutoCAD MIRROR command. It can be found under the "SCOOT" toolbar fly-out or the "Components" pull-down menu.

    UPDATE: A reader suggests... an even better place to find the command is right-click on the symbol and pick the command from the context pop menu!

    2 Comments | Add CommentIn Controlling the Machine > All

  • Customized INSERT PLC Module Command
    July 4, 2006 06:35 PMby Nate Holt

    This one was a challenge. A user wanted to create a new PLC I/O graphical style such that the terminal wire connection points would be embedded in the edge of the module's graphical outline. This can be done to some extent, right out-of-the box, except that the edge of the module will not "break" across the circle terminals.

    Here is a module insert using generic PLC style #3 and the left-hand module edge pulled in:

    plc01.jpg

    The left-hand edge of the module overruns the circle terminals. Not pretty. Not acceptable.

    To accomplish this fully, I thought an AutoLisp utility would have to be run against the module as a separate operation. It would do a quick REFEDIT, clean up the module edge, and then re-block. But I didn't think it could be done automatically at the same time the PLC module was inserted.

    BUT... the innovativeness and tenacity of Autodesk's Steve Kemp and Shirley Xie came through. They demonstrated that an AutoLisp utility could be called from a little-known feature within the INSERT PLC command and, if properly configured, the whole thing could be inserted and post-processed in real time.

    Here is the little chunk of AutoLisp code Download file that opens the module just inserted, flips it to REFEDIT mode, automatically looks for circle entities and breaks any LINE entities crossing them, and then re-blocks the module... all in a fraction of a second. and tied right into the INSERT PLC command!

    The trick is to have this code get called from the INSERT PLC module command and "auto-execute" when it gets loaded. The file name of this code is embedded in the module's PLC definition and graphical style number from the "PLC Database File Editor" as shown below:

    plc02.jpg

    Now, with this in place, inserting this particular module and graphical style #3, the module pops in and then the left-hand edge breaks across the terminals, all in one smooth operation.

    plc03.jpg

    Pretty cool.


    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