Autocad Electrical Vba Get Drawing Properties
When you add properties to your AutoCAD Electrical drawings most of these values are saved on the attributes on the drawing's WD_M block. However, when you add drawing description, section, or sub-section values they are not written to the drawing's WD_M block but are saved in the project's .wdp file.
Because these values are not saved on the drawing, when you want to reuse drawings from one project in another project, these values are not maintained. Say you are starting a new project that has some similarities to a couple of previous projects. So, you add the drawings you need from each of the previous projects in to your new project. But, because the drawing description, section, and sub-section values didn't come in with the drawings you have to re-enter them all. This is exactly the issue that was brought up in a recent discussion forum post. James Alger, our guest author (read about James below), and I decided to see if there was something that could be done to bring those values in, saving the time to re-enter all the information.
It turns out that when you enter the Drawing Properties, AutoCAD Electrical also saves this information to the AutoCAD Custom Properties. Use the AutoCAD DWGPROPS command to see the custom properties.
So we decided to see if a Lisp function could read the description, section, and sub-section values from the AutoCAD custom properties and write them to the project's .wdp file. Once they are in the .wdp file then AutoCAD Electrical sees them as Drawing Properties and can use them for the title block update, the Drawing List Report, etc. We also wanted something that could read the custom properties on each drawing whether the drawing was open or closed. And finally, we wanted it to work on AutoCAD Electrical 2013, 2014, or 2015.
What we came up with is a command that you run after you add the drawings to your project but before you edit any Drawing Properties. This way the custom properties are still there and can be read by our lisp command. To give it a try, follow these steps:
- Download the.zip file at the end of this post.
- Unzip the file to C:\ProgramData\Autodesk\ApplicationPlugins. It creates a new folder, C:\ProgramData\Autodesk\ApplicationPlugins\Draw_Props.bundle.
- Launch AutoCAD Electrical 2013, 2014 or 2015.
- Activate the project that contains the drawings you added from other projects.
- Type UPDWDPFROMDWG at the command line. (It should auto-complete saving you from typing the entire command name.)
- Select which properties you want to update and whether to overwrite existing values in the project .wdp or update only blank ones.
- Select the drawings to process.
The new command reads each drawing you selected and writes the description, section, and sub-section values to the project .wdp file. Once you run this, try using the AutoCAD Electrical Drawing Properties on any of the drawings processed and you'll see the values now.
This was a fun collaboration. I (Pat Murnen) wrote the initial lisp function. A special thanks to Lee Ambrosius, Principal Learning Content Developer at Autodesk, for helping with the ActiveX commands needed to make it work on the open or closed drawings. James tested it in AutoCAD Electrical 2013, 2014, and 2015 and provided feedback and suggestions. The first draft needed to be loaded manually and had some trouble working in 2013. I made some changes in the lisp function for 2013, Lee created the bundle so that it would load automatically in AutoCAD Electrical 2013, 2014, and 2015, and James tested it all again.
By the way, we did log on the AutoCAD Electrical IdeaStation that it would be nice if AutoCAD Electrical brought these values in automatically when drawings are added to a project. But, until that happens, use and modify the attached lisp function as needed. The lisp function is provided as "use at your own risk", not as an official AutoCAD Electrical command. It is provided with the source .lsp file in case you want to change it. Maybe you don't want to see the dialog, but want it to always update all non-blank values. You can set those defaults in the .lsp file and comment out the lines for the dialog. Or maybe you want to change the command name to something shorter. Even if you don't know much about Lisp, there are comments in the .lsp file indicating how to make these changes. We hope it saves you some time as you reuse drawings in other projects.
You can find out more about the WD_M block in the Help topic, About the WD_M Block, and more about the project .wdp file format in the Help topic, About the Project .WDP File.
About James Alger, our guest author and collaborator, in his own words: I work for an Autodesk Reseller in Canada (Redcage Solutions), where I provide Technical Support, Training, and consulting services. I have been working directly in the Autodesk Community for about 5 years now, prior to that I was a PLC programmer. I have done electrical schematics (For Automotive), Panel wiring, and of course programming (Robots and PLC's… no lisp sorry). I have used AutoCAD Electrical since 2009 (when I started in the re-seller channel), prior to that I did schematics in Plain AutoCAD… and I'll never go back! In addition to AutoCAD Electrical I also regularly work with Inventor, AutoCAD ("Vanilla" & Mechanical), and Vault.
Download Draw_Props.bundle
By Pat Murnen and James Alger
The comments to this entry are closed.
Source: https://autodesk.typepad.com/systemsdesign/2014/08/drawing-properties-stored-in-the-project-wdp.html
0 Response to "Autocad Electrical Vba Get Drawing Properties"
Post a Comment