Syndicate content AutoCAD Electrical Etcetera
Nate Holt's blog on all things AutoCAD Electrical
Updated: 59 min 25 sec ago

Spreadsheet –> PLC I/O Generator utility – tracing with Visual Lisp Debugger

Wed, 02/17/2010 - 15:15

Quick steps on a simple way to use the Visual Lisp Debugger to trace program execution of the Spreadsheet–>PLC I/O AutoLISP utility in AutoCAD Electrical.

The last posting and the Autodesk webcast on the Spreadsheet –> PLC I/O utility in AutoCAD Electrical generated a lot of interest. One user wanted to take the plunge and consider customizing the source code for this utility (file “wdio.lsp”). But he wanted to get familiar with using the Visual Lisp debugger to trace this utility as it executes and builds the I/O drawings.

Here’s one simple way to launch the Spreadsheet –> PLC I/O utility from within the Visual Lisp environment.

  1. First, find the path to the wdio.lsp utility on your machine. One way to find this is to type this at the “Command:” prompt.

(findfile “wdio.lsp”) [Enter]

2. Now start the Visual Lisp editor. Type VLIDE [Enter] at AutoCAD “Command:” prompt. Select “Open File…” and browse to the wdio.lsp utility (path you’ve found above).

 

3. Select the “Load Text in Editor” option as shown here:

4. At this point you should be ready to go. Maybe set a breakpoint at a key spot in the program… let’s say where the utility first starts to insert the blank “ladders” into the active drawing. Search the wdio.lsp text file for the ladder API command substring “c:wd_in_ladder”. Pop in a breakpoint here as shown.

5. Now put your cursor back into the AutoCAD command window. Type wdio [Enter] at the Command: prompt. This should launch the program, now in the Visual Lisp debug environment, and it should stop and display at your first break point. Have at it!

Categories: Autodesk feeds

Automation of PLC I/O Drawings – AutoCAD Electrical

Thu, 02/11/2010 - 15:20

Overview of AutoCAD Electrical’s Excel Spreadsheet –> PLC I/O Generator Tool.

Autodesk’s Dustin Clark hosted a webcast this morning on this “open source” tool in AutoCAD Electrical. I helped put the demo together and was responsible for the real-time Q & A support while Dustin was on stage.

Well, Dustin’s presentation generated a huge wave of feedback and kept me busy well past the conclusion of the formal presentation time responding to texted questions. So much so that I feel compelled to reproduce a number of the webcast slides and include detailed answers to the questions that they raised.

First of all, this tool in AutoCAD Electrical deals with complete I/O modules with the devices and wiring that connect up to each I/O point shown right there on the full module’s drawing. It is not set up to operate in the other popular mode… that is, to sprinkle discrete I/O points throughout the control design and then cross-reference each back to some master copy of the I/O module. Though this is possible in AcadE, it’s not the method that this “Excel –> Drawing generator tool” is designed to automate.

Dustin mentioned that often the first step you take in tackling a new controls design project is to collect a list of the project’s input and output requirements.

And, if you use an Excel spreadsheet to help arrange your project’s I/O list, then there may be a good chance that you can feed this to AutoCAD Electrical’s “Spreadsheet –> PLC I/O” tool and generate a first cut of your project’s I/O schematics.

Note: this AutoCAD Electrical Spreadsheet –> PLC I/O tool expects to work with Excel 97 – 2003 “.xls” format (not “.xlsx”). It can also work with an Access “.mdb” file format or with an ASCII text “.csv” file format.

Dustin’s first demo – starting very simply

The flow of the webcast demos was to start with a bare-bones I/O list spreadsheet and examine the generated I/O drawing set. Then, with each subsequent demo, add more design detail to the spreadsheet and see how that maps to each new version of the generated drawing set.

Here in Dustin’s first demo, project size suggests that we’ll need to allocate four I/O modules for our new project: two 16-point / 120 VAC input modules, one 16 point 120 VAC output, and one 8-point 24VDC output module. We initially specify AB series 1794 Flex I/O.

Since these modules are supported in the out-of-the-box AutoCAD Electrical product, we simply enter the catalog part numbers in the first column as shown here. Make sure that there is a blank row inserted between each module.

Note: Dustin’s demos use the default spreadsheet column format. This means the I/O module’s part number is in the first column, the I/O point addressing in the 5th column (E), and I/O point descriptions begin in the 7th column (G). But this is pretty much user-adjustable in the utility’s user interface dialog (not covered in the webcast but fully covered in the on-line help!).

So, we save our Excel file above. Then launch the PLC I/O Utility from the AutoCAD Electrical ribbon button shown here. Accepting all the defaults, two new I/O drawing generate showing four modules appropriately spec’d to match the AB 1794 series of Flex I/O.

Note: for earlier versions of AutoCAD Electrical, launch the tool from the pull-down or from the tool-bar pull-down as shown below.

Dustin’s second demo – Expanding spreadsheet to define description text for each I/O point

This next level of detail:

  • We add in a new row for each I/O point of each module
  • For each I/O point we enter up to five chunks of description text for that I/O point.

Note: One thing to remember, we MUST keep a blank row inserted between the end of one module and the beginning of the next.

Now, re-running the tool, we get a new set of drawings with the individual I/O point descriptions included (below).

Note: each time this tool runs, it creates a fresh set of I/O drawings. It does NOT incrementally update an existing set of I/O drawings with edits you make to the existing spreadsheet. There are other AutoCAD Electrical tools that can do this to a certain extent, but were not covered in this webcast.

Third demo – adding more detail to Spreadsheet – connected in-line devices

Now Dustin adds a bunch of new columns in groups of four, one set for each potential in-line device position (room for nine sets per I/O point). This is the AutoCAD Electrical default – four columns per I/O device. But you can expand this as required. See the on-line help.

Note: probably the hardest part of this is figuring out what device “block name” to enter into the “*BLK” column for each device. For example, if you want a N.O. pushbutton symbol to pop in for a certain I/O point, you need to enter a block name “HPB11″. If you want a N.C pushbutton, you’d need to enter “HPB12″. A little list of common symbol block names will probably be very useful here ( ! ).

With this extra in-line connected device information included in our Excel spreadsheet, newly generated I/O drawings are much more complete:

Here is a close-up of the top part of the first module’s connections. Each group of four columns in the spreadsheet drives what goes in to a connected-component column in the generated drawing.

Note: for an output module’s I/O point, the columns are reversed. The left-most group of four columns is the set farthest from the output point. The 9th group would be the set closest to the module I/O point.

Here’s a close-up below. This is a detailed look at just one of the columns and how the data from the spreadsheet both drives what component is popped in (the “S” column here) and the annotation that then goes on to the component (the 1st, 2nd, and last columns).

Note: the “|” pipe symbol in any of the *DESC columns is a delimiter that breaks the single line of text across consecutive “DESC*” attributes on the target symbol. In the example “CYCLE|START” below, the text “CYCLE” will try to go to the DESC1 attribute on symbol HPB11 and “START” will try to go to the symbol’s DESC2 attribute. If another pipe symbol delimiter, the remainder would try to go to the symbol’s attribute DESC3.

Dustin’s fourth demo – piggy-backing additional attribute/value combos into the spreadsheet

The setup for this one was this:  Let’s say we know the pressure switch settings that need to be documented for these two switches. It would be nice to just enter these values in the spreadsheet and have AutoCAD Electrical pull them across to each switch symbol’s “RATING1” attribute value.

Just add a piggy-backed attribute name/value to an existing column’s value. Don’t try this in the “block name” column. Use one of the other three columns reserved for the inserted component’s position. The format is “;” semicolon followed by attribute name, “=“ sign, and then the attribute value. You can piggy-back more than one extra attribute in a given Excel cell. Just delimit with a “;” semicolon character between each.  

If the column’s cell is blank to start with, begin with a semi-colon character. For example, if you want to use a blank “LOC” location cell to add some piggy-backed attribute values, begin with a “;” as first character.

Note: the target block instance needs to have the target attribute tag on it. If not present then the piggy-backed entry in your spreadsheet will have no effect. In the example above, the N.O. pressure switch symbol HPS11 carries a blank RATING1 attribute. So the above works great.

Fifth demo – inserting a “circuit” as an in-line wired device instead of a block insert symbol

 This was Dustin’s setup: Here’s where it gets more interesting. Not everything hooked up to a PLC I/O point is a single wire in and single wire out. Sometimes the device might have multiple connections or there might be a couple devices wires in parallel and tied to a single I/O point. Here’s an example of a pushbutton in parallel with a 2-position selector switch. Maybe we use this over and over in our designs and we always want to tie this combination in to one I/O point. 

Use AutoCAD Electrical to make a small sub-circuit consisting of an AutoCAD Electrical pushbutton symbol and a selector switch symbol and then just WBLOCK it out, let’s say to file name JOG_CIRC.dwg.

Now, in our spreadsheets, now and in the future, whenever we want to pop in this standard sub-circuit, we just enter it as shown here. Make sure that the WBLOCKed sub-circuit file name has the leading “*” character and that the circuit file is in an AutoCAD search path. In this example we also add a “SPACER” keyword to pull an extra gap in the module to clear up enough room for this sub-circuit to pop in.

Note: it is important that the circuit be saved in a folder that is included in AutoCAD Electrical’s search path or the general ACAD search path. If this is not possible, you can enter the full path into the Excel cell. IMPORTANT: if you encode the full path, you MUST use either double back-slashes or single forward slashes in the path/file name!

Running the AutoCAD Electrical spreadsheet to PLC I/O utility and referencing our modified spreadsheet… !  There’s our sub-circuit inserted into the wide gap in the PLC I/O module.

Note: circuit component tags will auto-tag if parent symbols, but no provision in the spreadsheet to push specific attribute values to specific parts of the inserted circuit. Doing this would require some customization of the program. Do-able, but outside the scope of Dustin’s webcast.

 

Configuring this Excel tool to your spreadsheet format and your drawing layout

 There is an extensive UI (partly shown below) that allows you to reconfigure this tool to better match up with your spreadsheet layout and generate drawings based on your standards. The webcast just used the AutoCAD Electrical “demo” defaults.

Delving into this part of the tool would have far exceeded the hour we had for the webcast. But all of this is pretty much covered in the AutoCAD Electrical on-line documentation.

 

Webcast posting for rerun viewing…

This webcast should be available at this link, or go to the main site here:

http://resources.autodesk.com/msd/AutoCAD_Electrical/Webcasts

Additional notes

This Spreadsheet to PLC I/O generator tool is supplied in basic AutoLISP file format. If you’re adventurous, it begs to be customized. The file name is wdio.lsp. You can find it on your AutoCAD Electrical installation by typing this at the command prompt:

(findfile “wdio.lsp”) [Enter] 

There is also a wdio.dcl dialog definition file in the same folder. That’s it. You modify this lisp file (make backup first!) and you can alter what the Spreadsheet –> PLC I/O tool will do.

Here are four blog postings that give step-by-step examples:

PLC I/O Drawing Generator – Pre-defining wire numbers

User enhancement to Spreadsheet-to-PLC I/O drawing tool (trim dangling wires)

SS->PLC I/O utility – adding auto title block update

A couple SS->PLC I/O Tricks – Pin number assignments

Afterword / Advertisement

If your company sees potential in a custom application and it exceeds your internal resources to bring it to pass, please consider N8 Consultants.

Categories: Autodesk feeds

Align Attribute utility

Wed, 02/10/2010 - 15:18

Pick master attribute and then pick one or dozens of other attributes from multiple block instances to align with it.

Steve Kemp responded to a user request on the AutoCAD Electrical discussion group by developing this cool little utility. He passed it on to me for posting here.

Here is an example of how it might be used. Let’s say that you have a column of terminal block inserts that are wired to a PLC module block insert. But, for this one drawing, you’d like to relocate one of the attributes to the left-hand side of each terminal block instance.

Here’s how to do it with Steve’s tool. First, use normal AutoCAD grips to position the attribute of one instance to the desired position.

Next, APPLOAD Steve’s little AutoLISP utility here. Type AATTR [Enter] at the command line.

Now pick on the one relocated attribute. Choose “vertical” alignment (default).

Hit [Enter]… and there you go! Everything neatly aligned with the master.

Current limitations: as written, the utility does not process attributes that are set to “FIT” or “ALIGN” justification.

About Steve Kemp… in addition to applications development (contact him at skiflea@mchsi.com), Steve likes to surf. Though trapped in the heartland of the US, if he loads his boat down with 1600 or so pounds of dead weight so that it sits low in the water and then drives 9-11 MPH, it will throw up a wake large enough to surf!

Categories: Autodesk feeds

AutoCAD Electrical update – your ideas?

Wed, 02/03/2010 - 14:43

A missing piece? A bump in a workflow? An awkward work-around?

Autodesk is soliciting comment / feedback for their ongoing effort to improve the product.

What simple improvements could result in a major gain in your productivity?

I have already submitted my list. I urge you to do the same. You can reply to this thread or enter via this survey link.

Categories: Autodesk feeds

Multiple Users on a Single AutoCAD Electrical Project – Q and A

Thu, 01/28/2010 - 23:14

Questions about this subject have popped up in my email recently – multiple times and from multiple sources. Here is a compilation of the typical questions and my emailed responses. Hope this helps explain how it all works! – Nate.

Q1. Is it possible to have multiple users working on the same AutoCAD Electrical project at the same time?  [Nate reply: Yes, but the normal AutoCAD limitation applies... only one user can have a given drawing active for "write" at a time. In other words, multiple users can be working in a common AutoCAD project but they need to be working on different drawings in that project - same limitation as normal AutoCAD.]

Q2.  Okay, but are there any limitations when two or more users work simultaneously in a single project (but on different drawings)? As I saw in the discussion group, the users should/must access the same project database.   [Nate reply: No, each user has his own copy of a project database that is on his local machine. What is common among multiple users working on the same project is the set of AutoCAD dwg files. Let’s say the project name is x:\projects\customer001.wdp and the drawings are on some network drive. Each user who makes this common project an active project will trigger the local copy of AutoCAD Electrical to create a copy of the scratch database file in the local machine’s AutoCAD Electrical USER folder.]

Q3. What is the file name of the local project’s scratch database file and where is it stored? [Nate reply: It's in the "USER" folder defined for AutoCAD Electrical. You can see the full file name displayed in the Project Manager window as shown here. Highlight the project name in the PM window. The scratch database path and file name is shown in the "Details" window. Programmatically, you can get this path/file name by executing this Lisp function:  (c:wd_mdb_get_proj_scratch_dbnam nil) [Enter].

Q4.  There are some batch operations in AutoCAD Electrical (e.g. reports, update, retag); is there any problem, if more than one user works in the project – because drawings by other users are locked?  [Nate reply: same limitations for regular AutoCAD apply to AutoCAD Electrical. Only one user can be modify a drawing at one time. AutoCAD Electrical will TASK operations that need to be applied to a drawing that is opened by some other user.]

Q5. Is it possible (or is it by default?), that the project database is always up-to-date? That every (logical) change in a drawing is immediately written back to the database? [Nate reply: the database will be kept up-to-date but this is not instant. There may be a delay, and the delay grows longer as the project gets larger. But hopefully the delay is not more than 5-10 seconds under most conditions.]

Q6. Let say I have projects with up to 1.000 pages in one project; is it useful (for performance) to divide the projects in some smaller projects and combine them to a super project (accordingly to an article in your blog)?   [Nate reply: yes, it is good to break the project up into logical sections (when practical) to improve performance... and then have one overall "super" project that you make "active" when complete reports and such are required across all subsections of the project.]

Q7. Okay, in a multi user enviroment, each user has his own scratch database, as you mentioned. But one thing, I don’t understand: if user A places a fuse with tag F1, how does AutoCAD Electrical know, that for user B the tag F1 isn’t anymore available? In a single user environment, I get the message ‚ “Duplicate Component”. [Nate reply:  User “B’s” copy of the scratch database will not know about “F1” until user “A” does a “QSAVE” on the edited drawing. This causes the time/date stamp on the edited drawing to change. User B’s copy of AutoCAD Electrical will see that one of the drawings is “out-of-date”. It will read that drawing and then update user B’s copy of the scratch database. Now user B’s copy of AutoCAD Electrical knows that “F1” fuse tag is no longer available. So, the key is that user A needs to assign the tag but those tags are not visible to other users on the network until user commits his changes (via a QSAVE of the drawing).]

 UPDATE: added Q7

Categories: Autodesk feeds

Overview of Simple BOM reporting – AutoCAD Electrical

Thu, 11/19/2009 - 06:20

Brief overview of how two different databases are queried to create various AutoCAD Electrical BOM reports.

This question comes up from time to time, most recently today. Here is a brief summary in the form of screenshots illustrating how a component on an AutoCAD Electrical drawing (a mechanical footprint symbol on a panel layout drawing) finds its way on to a BOM report. This illustrates just a simple, straightforward catalog assignment – without “ASSYCODE” and without “Multi-BOM” catalog assignments (future posting!).

A small portion of one drawing, DEMO08.dwg, which is part of a sample AutoCAD Electrical project drawing set “WDDEMO”, is shown below.

AutoCAD Electrical maintains a “scratch” database file, in Microsoft Access format, that follows what is going on in the project drawing set (it does not drive it, it follows it). The above mechanical footprint component, SS433 on drawing DEMO08.dwg of the project, shows up in the “PNLCOMP” table of the scratch database file for this project.

 The scratch database file name is the same name as the active AutoCAD Electrical project name but with an “.mdb” extension. It is saved in the local AutoCAD Electrical “user” folder. The full name can be displayed by typing this at the AutoCAD “Command:” prompt.

 Command:  (c:wd_mdb_get_proj_scratch_dbnam nil) [Enter]

 Here is a screenshot of the above panel component in the PNLCOMP table of the project scratch database:

And here’s another screenshot of the above record with a few other fields exposed. These fields are used to guide AutoCAD Electrical’s BOM reporting command to the appropriate “table” in the catalog lookup database file DEFAULT_CAT.mdb (shown shortly).

The actual table name that the BOM report queries for this “SS433″ symbol’s catalog description information is influenced by the WDBLKNAM value shown above. See this posting for a description of how auto-table selection works.

Ultimately, the BOM reporting goes to table “SS” in the DEFAULT_CAT.mdb file. It uses the MFG/CAT attribute values carried on the panel footprint symbol (and extracted into the PNLCOMP table shown above) to find the appropriate record in the “SS” table shown here:

And now the BOM reporting command merges the data in the record above with the data from the scratch database file. It is formatted into the report and shows up as an entry here in the BOM Report Generator dialog ( ! ):

Now, at this point, you can write the report out to a file (in various formats) or insert the report as a “smart” table on to your AutoCAD drawing.

Categories: Autodesk feeds

Feedback – Shaping the future of AutoCAD Electrical

Wed, 11/18/2009 - 13:58

The Autodesk development team responsible for AutoCAD Electrical wants your feedback. Here’s a note from Autodesk’s Jose Santos:

Are you interested in shaping the future of AutoCAD Electrical?

 The AutoCAD Electrical team is offering two great opportunities if you work with schematics for controls, switchgear, power, process, and instrumentation, and are attending Autodesk University 2009 in Las Vegas:

 Product Usability Evaluation

Various sessions. Nov 30 – Dec 3, 2009

Register here.

 Power, Controls, and Instrumentation Unplugged

November 30, 2009.  2-4pm

Register here.

 If you can’t attend but are interested in keeping in touch with the AutoCAD Electrical team for future events, register here.

Categories: Autodesk feeds

Enhanced wire number tags based on connected components – AutoCAD Electrical

Fri, 11/13/2009 - 01:45

Wire number tags based upon connected component tag-ID at each end.

Some time ago we had this posting that dealt with a wire numbering tool utility. It would generate a wire number tag based upon combining the tag-ID and termination pin number of the component connection at each end of the wire. This generated explicit but really “long” wire numbers.

Here’s an example:

wirenox_01

Yes, really long wire numbers ( ! )

Request for a Simplified Version

A user in Australia wanted to do this but make the tags shorter. He just wanted to concatenate the two tag-IDs and then add an alpha suffix to keep each wire number unique. No connection pin numbers embedded in the wire number.

For example, in the above drawing, the upper right-hand wire number would be the two device tags jammed together, “SS406TD406″, and an alpha sufffix, let’s say “A”.

Now there are two more wires that tie the same two devices together: the right-hand wire leaving the two child contacts on the selector switch. Both will be “SS406TD406″. So the utility would need to add a “B” and a “C” to each respectively to keep the wire numbers unique.

Modifying the existing milnum_alldwg.lsp utility

So, let’s start with the previous post’s lsp utility, copy it to a new file name, “milnumx_alldwg.lsp”. Open it up in AutoCAD’s Visual Lisp editor (type vlide [enter] at the “Command:” prompt) or open in any ASCII text editor (like WordPad.exe) and let’s have some fun.

Step 1 – this is the easiest part. We want to bypass the original utility’s task of adding in the connection pin numbers. Here is the before and after code:

BEFORE:

                    (if (= flipit 1)                       (progn ; reverse the order                         (setq new_wireno comp2_tag)                         (if (AND pin2 (/= pin2 ""))(setq new_wireno (strcat new_wireno "-" pin2)))                         (setq new_wireno (strcat new_wireno "/" comp1_tag))                         (if (AND pin1 (/= pin1 ""))(setq new_wireno (strcat new_wireno "-" pin1)))                       )                     ; ELSE                       (progn ; normal order of wire number format                                           (setq new_wireno comp1_tag)                         (if (AND pin1 (/= pin1 ""))(setq new_wireno (strcat new_wireno "-" pin1)))                         (setq new_wireno (strcat new_wireno "/" comp2_tag))                         (if (AND pin2 (/= pin2 ""))(setq new_wireno (strcat new_wireno "-" pin2)))                     ) )                        (c:wd_putwnf en new_wireno) ; put the wire number on wire AFTER:                     (if (= flipit 1)                       (progn ; reverse the order                         (setq new_wireno (strcat comp2_tag comp1_tag)) ; just jam two tags together, no delimiter                       )                     ; ELSE                       (progn ; normal order of wire number format                                            (setq new_wireno (strcat comp2_tag comp1_tag)) ; just jam two tags together, no delimiter                     )  )                       (c:wd_putwnf en new_wireno) ; put the wire number on wire

Step 2 – the harder part. Okay, we have the base wire number figured out above and pushed into lisp variable “new_wireno”. But we need to check each wire number and make sure it is unique. We add an incrementing alpha suffix to the wire number until it is unique.

This means that we need to first extract a list of all existing wire numbers on the active drawing (could do for all dwgs in project but that will be an upcoming blog posting). Then, when we generate a new wire number, we compare against the existing wire number list and, if a repeat found, keep incrementing the suffix for our new wire number until we find one that isn’t already in the list.

So, here’s a little subroutine we’ll add to our milnumx_alldwg.lsp utility. It runs at the front end of our utility to establish a list of all existing wire number assignments.

Here’s how it works… it creates a “selection set” of all wire number block inserts found on the active drawing. AutoCAD Electrical wire numbers have block names that begin with either “WD_WNH” or WD_WNV”. So the “ssget” line below gets all instances of wire number block inserts on the active drawing.

Then we cycle through this list, one at a time, and get each wire number block insert instance, the “(setq en (ssname sswn ixwn))” line below. Then we get the wire number attribute value, WIRENO or WIRENOF. Add to the running list of wire numbers, loop back to the top of the loop, and process the next wire number block insert instance. When done, all of the drawing’s wire numbers are sitting in AutoLISP variable “lst”. This data is returned from this function.

ALL NEW:

  (defun milnumx_get_all_existing_wirenums ( / sswn ixwn slenwn lst )     ; Extract a list of all wire numbers found on the active drawing. Create a selection     ; set of all block insert instances that have block name "WD_WNH*" or "WD_WNV*". There     ; are AutoCAD Electrical wire number block names.     (setq lst nil)     (setq sswn (ssget "_X" '((-4 . "<AND")(0 . "INSERT")(2 . "WD_WNH*,WD_WNV*")(-4 . "AND>"))))     (if (/= sswn nil)       (progn ; some wire number block instances found. Process them.         (setq slenwn (sslength sswn)) ; number of block instances found         (setq ixwn 0) ; this will be used to index through the blocks         (while (< ixwn slenwn)           (setq en (ssname sswn ixwn)) ; get next block instance entity name           ; Get WIRENO* attribute value off of this wire number block insert           (setq wn (c:wd_getattrval en "WIRENO*"))           (if (AND wn (/= wn "") (not (member wn lst)))             (progn ; add to the running list               (setq lst (cons wn lst))           ) )           (setq ixwn (1+ ixwn))     ) ) )     (setq sswn nil) ; release the selection set     lst ; return the list of existing wire numbers found on active drawing   )

Step 3 – Putting it all together. Now we add a call to our wire number collection function to capture a list of all wire numbers and dump into AutoLISP variable name “existing_wnum_list”. We do this toward the beginning of the utility as shown here:

  ; -- main routine starts here --                     ; Two options here. Uncomment first two lines and uncomment third line to prompt   ; user to "window" what wires to process. Or, comment out the first two lines and   ; uncomment the third line to process all wires on active drawing without any   ; user prompts. ;;;  (princ "\nSelect wire or wires to process for special source/dest wire number format") ;;;  (setq ss (ssget '((0 . "LINE")))) ; user windows what to process   (setq ss (ssget "_X" '((0 . "LINE")))) ; automatically process all wires on active dwg   (if (/= ss nil)     (progn       ; Get list of all existing wire numbers       (setq existing_wnum_list (milnumx_get_all_existing_wirenums)) ; ** 12-Nov-09 NEHolt                 (setq slen (sslength ss)) ; number of LINE entities selected       (setq lines_processed_entlist nil) ; used to track what has been processed       (setq ix 0) ; used to index through the selection set       (while (< ix slen)

… and we go back to what we did in Step 1. We add a “foreach” loop just below the point where we have generated the raw “component1-component2″ tag. We want to find the next suffix character that keeps this proposed wire number unique.

                    (if (= flipit 1)                       (progn ; reverse the order                         (setq new_wireno (strcat comp2_tag comp1_tag)) ; just jam two tags together, no delimiter                       )                     ; ELSE                       (progn ; normal order of wire number format                                           (setq new_wireno (strcat comp1_tag comp2_tag)) ; just jam two tags together, no delimiter                                            ) )                        ; Now add an incrementing alpha suffix to the wire number until                     ; a unique wire number is found (one that does not appear to have                     ; already been used elsewhere on this drawing).                     ; "existing_wnum_list" is the list of existing wire numbers                     ; collected for the active drawing.                     (setq alphalst (list "A" "B" "C" "D" "E" "F" "G" "H" "J" "K" "L" "M" "N"                                          "P" "R" "S" "T" "U" "V" "W" "X" "Y" "Z" "A1" "A2"))                     (setq hit nil)                     (foreach suffix alphalst                       (if (not hit)                         (progn ; don't have a unique number yet. Try this one.                           (setq x (strcat new_wireno suffix))                           (if (not (member x existing_wnum_list))                             (progn ; Yes, found next available suffix that yields a                                    ; unique wire number!                               ; Add this new wire number to the running list                               (setq existing_wnum_list (cons x existing_wnum_list))                               (setq hit T) ; to bypass the rest of this "foreach" loop                               (setq new_wireno x)                           ) )                     ) ) )                                                             (if (not hit)                       (progn ; didn't find a unique wire number suffix. Add "???"                         (setq new_wireno (strcat new_wireno "???"))                     ) )                     (c:wd_putwnf en new_wireno) ; put the wire number on wire

There it is. Let’s test. Save the above file. APPLOAD it. Then type MILNUM_ALLDWG [Enter] at the Command: prompt.

wirenox_02

Download full file here

UPDATE: found typo in the uploaded file (13-Nov-2009). Fixed and reposted.

Categories: Autodesk feeds

PLC I/O Drawing Generator – Pre-defining wire numbers – AutoCAD Electrical

Fri, 11/06/2009 - 16:02

Adding a new option to the “Spreadsheet to PLC I/O” drawing generator tool – pre-defining wire numbers right in the spreadsheet.

This AutoCAD Electrical tool is pretty flexible. Using Excel, you lay out your control system’s I/O module requirements and out pops a set of 75-80% complete PLC I/O drawings.

For example, the first three lines of this example spreadsheet drives the AutoCAD Electrical Spreadsheet to PLC I/O utility to generate the circuitry shown below. But wouldn’t it be nice if we could pre-define the existing wire number assignments that tie into the two customer-supplied interlocks?

wdio_wnum_00

wdio_wnum_01

How to add this new feature

This is not too difficult. One thing that makes it possible is that this Spreadsheet to PLC I/O generator tool runs is an AutoLISP function that runs totally bare. It is supplied and runs in full-source mode, file name “wdio.lsp”. This means you are free to modify your copy of this tool.

The second thing that makes adding this new option easy-to-do is that the tool is already set up to support “piggy-backed” attribute assignments.  For example, in the row of your spreadsheet for I/O point “I:003/10″ you’ve entered the block name for a N.O. temperature switch, block name “HTS11″. In the D3DESC column you’ve entered a description for this switch, “SLURRY HEAT READY”. But you’d also like to define the “RATING1″ value for this switch. But your spreadsheet has no column for RATING1 for the 3rd connected component. No problem. Just piggy-back the RATING1 assignment to the D3DESC value:

D3DESC value before:  SLURRY HEAT READY

D3DESC value after: SLURRY HEAT READY;RATING1=95C

We’ll use this same idea to flag pre-defined wire number insertion on each side of a component. Instead of a name of an attribute, we’ll use these names:  $WNL and $WNR for “wire number left side” and “wire number right side”.

So, let’s say that we want to pre-define wire number assignments “TS-100″ and “TS-101″ for this temperature switch in our spreadsheet. We’d enter this:

D3DESC value: SLURRY HEAT READY;RATING1=95C;$WNL=TS-100;$WNR=TS-101

So, that’s how we’ll set up our Excel spreadsheet to define wire number assignments. Now, the key piece is to modify the “wdio.lsp” file to be ready to recognize that a piggy-backed attribute name that is $WNL or $WNR is really a flag for a wire number insert.

Step 1 – find the wdio.lsp utility. A good way to do this is to type this at your AutoCAD Electrical ”Command:” prompt

(c:ace_find_file “wdio.lsp” 3) [Enter]

If it can be found, the full path will display. Ignore the doubled-up back-slashes. It’s a Lisp thing.

Step 2 – MAKE BACK-UP COPY OF wdio.lsp. Important! Safety first.

Step 3 – Open wdio.lsp with any ASCII text editor or use AutoCAD’s Visual Lisp editor (type vlide [enter] at Command: prompt)

Step 4 – find this function within wdio.lsp file

wdio_wnum_03

Step 5 – Carefully cut and paste the code below to replace everything shown in the screenshot above.

  ; --   (defun wdio_write_out_accum_extra_attr_data ( en lst2 / atnam atval x xx hit_wen lstx)     ; "lst2" = (list (list attrnam attrval) (list attrnam attrval) ...)     (foreach x lst2 ; ** 06-Nov-09 NEHolt.begin, N8 Consultants LLC            (cond         ((wcmatch (strcase (car x)) "$WNL,$WNT,$WNR,$WNB") ; Look for special wire number flag           ; masquerading as an attribute tag name. When found, the "attribute value" associated           ; with it will be the desired fixed wire number value.           ; The name of the flag indicates which "side" of the inserted component "en" that           ; the wire number goes with.           ; Get component's wire connection data           (setq lstx (c:wd_get_sym_pntlst en 1 nil))           (setq hit_wen nil)           (foreach xx lstx             ; Going through each wire connection returned from the component that was             ; just inserted (entity name "en"). Each sublist has the X?TERMxx wire connection             ; direction (the "?" part) held in (nth 4...) element. If any wires tied to             ; this connection, they are held in a list of entity names in (nth 3...) element.             (cond               ((/= hit_wen nil)) ; already processed this wire number, skip               ((= (nth 3 xx) nil)) ; no wire connected to this component connection, keep looking               ((AND (= (strcase (car x)) "$WNL")                     (= (nth 4 xx) 4)) ; connection direction is from the left                 ; Found wire connection on left side (wire connection direction "4")                 ; Push fixed wire number out to this wire connection's attached wire                                 (setq hit_wen (car (nth 3 xx))) ; save wire entity name & exit loop               )                ((AND (= (strcase (car x)) "$WNR")                     (= (nth 4 xx) 1)) ; connection direction is from the right                 ; Found wire connection on right side (wire connection direction "1")                 ; Push fixed wire number out to this wire connection's attached wire                                  (setq hit_wen (car (nth 3 xx))) ; save wire entity name & exit loop               )                ((AND (= (strcase (car x)) "$WNT")                     (= (nth 4 xx) 2)) ; connection direction is from above                 ; Found wire connection on top side (wire connection direction "2")                 ; Push fixed wire number out to this wire connection's attached wire                                  (setq hit_wen (car (nth 3 xx))) ; save wire entity name & exit loop               )                ((AND (= (strcase (car x)) "$WNB")                     (= (nth 4 xx) 8)) ; connection direction is from below                 ; Found wire connection on bottom (wire connection direction "8")                 ; Push fixed wire number out to this wire connection's attached wire                                  (setq hit_wen (car (nth 3 xx))) ; save wire entity name & exit loop                          ) ) )               (if hit_wen             (progn ; push the defined wire number out to wire entity "hit_wen".                    ; Insert it as a "fixed" wire number value.               (c:wd_putwnf hit_wen (cadr x))                      ) ) )             (T ; ** 06-Nov-09 NEHolt.end           (if (AND (not (c:wd_modattrval en (car x) (cadr x) 1)) (/= (car x) ""))             (progn ; target attribute name not found               ; If it is the format of CATxx, MFGxx, CNTxx, ASSYCODExx, or WDBLKNAMxx then write out as XData               (if (wcmatch (car x) "CAT??,MFG??,CNT??,ASSYCODE??,UM??,WDBLKNAM??")                 (progn ; write as XData                   (c:wd_upd_pnlval en (car x) (cadr x))                      ) ) ) ) )       )   ) )

Step 6 – save your modified version of wdio.lsp.

Now, let’s test.

Here we’ve opened up the demo PLC spreadsheet demoplc.xls and added some references. We changed the terminal block names from HT0001 to HT1001 so that wire numbers change through them. We’ve added a couple customer symbol references. Finally, we added in our wire number flags to insert wire numbers “W1″, “W2″ on the customer limit switch and “W5″ and “W9″ for the N.C. relay contact.

wdio_wnum_04

Save spreadsheet. Exit out of Excel. Cross fingers and fire up the AutoCAD Electrical Spreadsheet –> PLC I/O utility. Reference the modified spreadhseet, and watch what happens…

wdio_wnum_02

A few things to keep in mind with this modification:

1. Remember that terminals come in two flavors… those that maintain a wire number assignment through the terminal on those that trigger a wire number change through them. You might need to use the latter.

2. If you put the “$WNL=<wire number>” or “$WNR=<wire number>” flag in an empty cell in your spreadsheet, precede it with a semi-colon (ex: empty cell contents becomes ”;$WNL=12345″). This triggers the utility to treat this as a piggy-backed attribute.

3. For wires attaching from above or below, use flags $WNT and $WNB.

4. If these flag names don’t make sense or the “$” character is not one that shows up on your keyboard, adjust to suit your needs by editing the appropriate places in the pasted in Lisp code of step #5 above.

Advertisement – if your company is in need of AutoCAD Electrical customization, please visit http://n8consultants.com

Categories: Autodesk feeds