Showing posts with label Automation. Show all posts
Showing posts with label Automation. Show all posts

Friday, March 6, 2015

Running Scripts on Multiple Files – AutoCAD Electrical

Several times now I have been asked how to “do something” to every drawing in the project. The last one to come across my desk was to freeze all layers on all drawings project wide. AutoCAD Electrical actually has some really good tools for running scripts. I find myself turning to it even for non Electrical needs quite often.

Here are some examples I have encountered recently:
Updating the company address, or copyright year, on all title blocks
Swapping title blocks on all drawings (Swap/Update Block)
Zoom Extents, set limits, and export PDF
Add company standards (layers, dim styles, ect) to all drawings
Freeze all layers

Pushing a Script Project Wide

This method involves a script file (.scr). A script file consists of only what you would type in the command line. Start Notepad and type everything command there as you would in the Command Line. For example to freeze all layers and then do zoom extents your script file would look like this.
image

To test a script file simply drag and drop the file into the drawing window. The script will run and you will quickly see if it runs properly. If you script is complex, consider adding notes. Any line started with a semi-colon is ignored by the script file. Add comments starting with a semi-colon to make future edits easier to understand.

And now to run this script on an entire project. Make the desired project active and then choose Utilities from the Project tab.
image

In this dialog, select ‘Run command script file’ and select the script file to run. After pressing OK the option for project wide is the default.
image
 image

Pushing a Script On All Drawings in a Folder

This option is hidden under the Symbol Builder drop down menu. The command is Modify Symbol Library. This utility can be used to simply run an AutoCAD command or to run a script on all files in a folder.
image

The first thing the command asks for is a folder. After selecting the folder, the following dialog displays. I recommend creating a test folder with only a few drawings to prove out the script before running on a large number of files.
Check the Run AutoLISP box and enter a LISP command.
image

This dialog checks your LISP command for proper formatting. If something is wrong the following will display.
image

Any AutoCAD command can be run in LISP by simply starting with “command”. Remember all LISP lines are enclosed in parentheses ().

I entered the following to run my script file… (command "_.script" "C:\LayerLock.scr")
Press Start and sit back while AutoCAD Electrical does all the work.

Wednesday, April 23, 2014

Mass Migration of DWG Files Using AutoCAD Electrical

imageOver the weekend I ran into a case where I had several thousand DWG files that were older than AutoCAD Release 14. Vault would not rename them because of this. Inventor’s Task Scheduler wouldn’t migrate them for some reason either. After a few other attempts to migrate, I was running out of options. Then I noticed AutoCAD Electrical on one of the workstations! I checked all of the files out to that workstation, and then used the Modify Symbol Library utility to basically do nothing more than save each DWG.

 


 

The Start button remains greyed out even after checking the “Do a SAVE even if no change” box. The dialog wants some actual work. So I had it Zoom Extents on each drawing and that satisfied the dialog. This ran extremely fast! Much faster that Inventor’s Task Scheduler would have. We ran through several thousand DWG’s in under 30 minutes! Of course this workstation is running on SSD’s but still…

image

Friday, October 4, 2013

Making Changes to the ENTIRE Symbol Library – AutoCAD Electrical

I noticed this call coming into our support desk today. The user needed to change the scale of every symbol in the entire JIC or NFPA library. That’s quite the task to tackle manually. There are over 1,700 symbols in the NFPA folder with another 133 in the 1- subfolder. The IEC library contains over 3,300 symbols! Opening each and every symbol to simply change a scale or change an attributes text height is an extremely time consuming and monotonous task.

imageInstead of “there’s an app for that,” I can say wait “there’s a utility for that.” It’s slightly hidden. Its under the Symbol Builder button.

Make a backup of the library folder first of all. Then start the Modify Symbol Library utility. After selecting the library folder to modify, the final dialog allows all kinds of changes. Also note the ability to run a LISP expression. So pretty much anything can be done to each and every symbol in the library.
image

Thursday, September 5, 2013

I Need More Fields! – Pushing Past The Limits of Title Block Update

Many companies have had to settle with placing some “specific” field in one of the ten default Drawing Properties. It could be as simple as needing a forth description line. Since there are only three default description fields, the forth description line more than likely ends up in the Project Code field.

Another example could be needing semi-project wide descriptions. The Title Block Update utility can become too restrictive in these instances.

I went on a quest to find the easiest way to push ALL title block attributes out to a spreadsheet and then pull the changes, project wide, back into Electrical. As always, please comment or e-mail me if you know of an easier/better way.

After some initial testing, I finally decided to focus on the existing Export To Spreadsheet utility.

Any block with a TAG1 attribute is exported using the Components option. So simply add an invisible TAG1 attribute with a default of TITLE. Also add another invisible attribute named LOC and add a default value of TITLE. This will allow us to create spreadsheets with only the title blocks.

imageNext we need to create a <<default.wda>> file.  Using the User Attributes command makes creating this text file quite easy. From the Reports tab click on User Attributes and then add all title block attributes to the list. These attributes will now be available in any of the component type reports.

This would be placed in the same support location the title block mapping file (.wdt) was placed in. Some networked support path or inside the active project folder.

 

image

imageThat’s it! We are ready to export all title block attributes project wide. From the Import/Export Data tab select To Spreadsheet. Select Components from the resulting dialog and press OK.
imageimage

The next dialog (Component Data Export) sets the scope of the export. In this case we want Project and a Named Location of TITLE. Pressing Drawing will show the list of locations and TITLE should be listed.

Press OK and specify a location for the Excel file. After opening the Excel file, scroll all the way over to the right and all the User Attributes will be listed with the values pulled from the drawings.

Once all needed changes to the title block attributes are completed its time to import back into AutoCAD Electrical.

Again from the Import/Export Data tab, but this time select From Spreadsheet. It should remember the name and location and simply require the press of the Open button. Worse case you may need to browse back out to the file location.

 

imageThe next dialog has a cool option that will force all spreadsheet values to upper case. Press Project and OK and all new values will update in each sheets title block.

image

 

 

 

The title blocks should not show on any BOM reports because of the lack of catalog information. To exclude them from the Component report place ~TITLE in the location code. This will exclude all blocks with a location of TITLE.

Thursday, August 8, 2013

Adding Cross Reference (XREF) Info To Footprints – AutoCAD Electrical

imageToday I was asked how to pull cross reference info from the parent symbol into a footprint. This works great on child components. Simply add an XREF attribute to a child component (if its missing) and on placement it auto populates with the parents sheet and reference location. However add an XREF to a footprint and nothing happens to it.
Out of the box, footprints do not pull this information even if the footprint contains an XREF attribute. However this information is available because multiple commands reference the footprints back to the parent symbol. None is more visible than the Surfer

image

In the surfer dialog above we can clearly see a reference between the parent, a child, and the footprint. So the question is, how do we go about getting this information info the footprint?
Below is a nifty utility wrote by Nate Holt back in 2009. (I tested it in 2014 and it still works great) It uses the same calls to the database that the Surfer users to capture this information and then writes it into an attribute named XREF on all the selected footprints.
Simple APPLOAD it and then type the command PANEL_CROSSREF

Add an XREF attribute                 Run the command                   Select the footprint                 Press enter…
image   image  image image

Sunday, June 30, 2013

Running a LISP, or Command, on File Open - (Fix_Me)

You can set a LISP utility to run each time you open a drawing from the Project Manager. This is set in the wd.env file. Look for the line that starts with *WD_OPEN_DWG.
         <<Link to my post about the wd.env file>>

“How do I mark a symbol/wire that has a problem, or missing information, and later quickly find it?” Last week this question came up again.

Below is some code that you can find inside of Electrical’s help as sample LISP code. Simply copy and paste it into a text file and save the file as Fix_Me.lsp. APPLOAD this file.

(defun c:fix_me ( / ss en ed xy)
  ; Look for any block insert on the drawing with a block name of "FIX_ME"
  (setq ss (ssget "_X" '((-4 . "<AND")(0 . "INSERT")(2 . "FIX_ME")(-4 . "AND>"))))
  (if (/= ss nil)
    (progn ; one or more found. Zoom up on the first one found
      (setq en (ssname ss 0)) ; entity name of first or only block
      (setq ss nil) ; release the selection set
      (setq ed (entget en))
      (setq xy (cdr (assoc 10 ed))) ; block insertion point
      (command "_.ZOOM" "_CENTER" xy 1.0)
      (princ "\nThis needs attention!!!\n")
  ) )   
  (princ)
)

Typing ‘fix_me’ will now run the script which zooms in on the first block named fix_me that the script finds. So create a block named fix_me and give it attributes for notes as well as all symbol attributes. This fix_me symbol can then be used when a needed symbol is missing and the engineer is waiting on the CAD Admin to create it. Once the new symbol is finished the fix_me symbol can be swapped (Swap/Update Block) with the new one. Values in the attributes will carry across to the new symbol. It could also be placed off to the side of a symbol with missing catalog info, or anything else the engineer is unsure of at the time of placement.

So once the LISP file and block are created, why not run them each time a drawing is opened? This takes us back to the WD_OPEN_DWG line in the wd.env file. If your block and LISP files are both named fix_me replace the default *WD_OPEN_DWG line with this…
WD_OPEN_DWG,(if(not c:fix_me)(if(setq x(findfile "fix_me.lsp"))(load x)))(if c:fix_me (c:fix_me))

Pretty slick right.

Wednesday, February 6, 2013

AutoCAD Electrical - Wire From/To Annotation On the Schematic

I have used this twice in the past. It's not quite what the customer wanted but its close. I think with a little tweaking it could be perfect.

AutoCAD Electrical is not set up to show From/To tags on the schematic. All the info is there but only available in reports. But it is not set up to actually INSERT pieces of "smart" from/to text right on each connection of the schematics.

Here is a small AutoLisp utility created by Nate Holt. 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.

And here is what it does:
   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 on and off.

Here are the before and after screen grabs. The tag-ID and pin number for the opposite end of each wires connection point. Note that CR408 shows multiple connections on both sides.

      image             image

Wednesday, January 16, 2013

Title Block Update - Merging Multiple Fields Into One Attribute

This week a user was asking for multi-line attributes. After reading a few posts online about Electrical Title Block Update not being able push to multi-line attributes I had to figure out a work around. But here's the trouble, in my very first test the Title Block Update utility pushed, and wrapped, data to my multiple line attributes. So at some point this functionality was added to Electrical and the post I had noticed must have been old.  So its back to the user to see what version they are using. Turns out want the user really wants is the description line 2 to move down as description line 1 wraps.

So the new puzzle is how to push text down as attributes wrap.

         Basically to turn this...                                          into this....
image      image

Tuesday, January 15, 2013

Updating All Drawing Settings (Descriptions) Using Excel

imageI was recently asked why the Drawing Descriptions were not updating after a user edited the project file (.wdp). The user was correct in that this information is stored in the project file.

However changes to the text file may require the project to be closed and reopened for Electrical to see the changes.

image

Another limitation to direct Project File edits is that only the Descriptions are stored there. The other fields are stored inside of each drawings wd_m block.

Monday, January 14, 2013

AutoCAD Electrical's Title Block Update - Previous / Next Sheet Numbers

Several times now I have been asked for Previous/Next page numbers on the title block. This is something that Electrical cannot do out of the box. However with a little scripting and the Title Block Update utility its very possible. So in this post you will get to see two things. Automatic Previous/Next page numbers and tying scripts to attributes using the Title Block Update utility.

The Previous / Next Page Number Issue

imageSome companies use a page numbering system where each group of drawings has a set series of page numbers. For example, The first five pages are for "power" followed by five pages of "controls", ect. For this type of numbering it would be very nice to see what the previous or next page numbers are. And it would be even better if AutoCAD Electrical could do this automatically.

So how can we get AutoCAD Electrical to figure these out and map the values to attributes on in title block? This is where a script comes into play. AutoCAD Electrical allows us to embed an AutoLISP expression into the mapping file (.wdt) and link it to a title block attribute. The returned value from this expression gets inserted as a text value in the linked attribute.

Saturday, January 5, 2013

AutoCAD Electrical's Title Block Update - Mapping Project Wide Revisions

If you bump revisions on each page with any change, consider using the Title Block Update utility. There is no halfway here. For the utility to work either ALL sheets are bumped or they are not. As with any automation, the process must remain consistent.

In this post we are going to push the Title Block Update just a little. We are going to have two blocks that auto update in the project's drawings. First a title block and second a revision block. Below are exploded views of both blocks I plan to use in this example.
image

Thursday, January 3, 2013

AutoCAD Electrical's Title Block Update - The Basics

Typically all the drawing title blocks in a project share much of the same information. Using the image "Title Block Update" utility from the Project tab, you can automatically update all the title blocks in the entire project with mapped information.

Project Descriptions can be pushed to ALL title blocks in the project. Drawing Settings can be pushed to each individual drawing's title block.

image  image
Now that you know what can be pushed lets see it in action.

What Makes it tick?

Wednesday, June 27, 2012

Mass DWG Save-As Back To An Older Release

imageThis question came up during a support call. Thinking this had to be a common request I immediately started looking for a LISP of some type. The caller mentioned the Autodesk site said something about DWG True View doing this. I would have never thought of turning to a viewer for a mass converter.

However here it is...
image

Drawings can be added from several folders at once and then saved in place or to a predefined folder.
image
Select the version to save back to and press Convert
image
There are several predefined conversions setup but you can create your own as well. Here are the options for setting up a custom conversion style.image

Thursday, April 5, 2012

Auto Trim Wires from the PLC I/O Utility

If you are using saved circuits with the PLC I/O utility, you more than likely end up with a few wires that are not needed. There may also be times when you simply need to remove a wire from one side of a component.

Here is an example of how the saved circuits come in is inserted manually.
image However when using the PLC I/O utility they look like this. The utility runs a wire to each terminal!
image

Thursday, January 20, 2011

Creating a custom PLC style in AutoCAD Electrical

There are 5 predefined PLC styles provided with AutoCAD Electrical, numbered 1 through 5. If none of the 5 work for you they are not that difficult to modify.
                                     


clip_image002
Default Style


clip_image004
Modified Style















Friday, August 27, 2010

AutoCAD Electrical and Inventor – Follow Up

As promised here are a few things to watch for when using AutoCAD Electrical and Inventor’s Cable and Harness environment together.

Monday, August 23, 2010

Hydraulic, Pneumatic, and P&ID Schematics In AutoCAD Electrical?

Many of you know that AutoCAD Electrical does a wonderful job assisting in the creation and modification of Electrical Controls schematics. But did you know it can also be used to produce Hydraulic, Pneumatic, and P&ID schematics, as well? It sure can.
The Extra Libraries toolbar has been available since before it was even AutoCAD Electrical and those three Icon Menus continue to be available with the introduction of the Ribbon.