Through the Interface: Customizing ScriptPro 2.0 to process drawings not present in the AutoCAD editor

May 2015

Sun Mon Tue Wed Thu Fri Sat
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30


« Transforming a list of RegAppIds from XML to HTML using XSLT | Main | February’s Plugin of the Month live on Autodesk Labs: AveragePoint for AutoCAD »

February 02, 2011

Customizing ScriptPro 2.0 to process drawings not present in the AutoCAD editor

It’s time to wrap up the series on batch-reporting Registered Application IDs. For reference, here’s how we got to where we are today:

  1. Implement a command to collect RegAppId information for the active document
  2. Extend this command to work on a drawing not loaded in the editor
  3. Save our RegAppId information to some persistent location (XML)
  4. Create a modified version of ScriptPro 2.0 (one of our Plugins of the Month) to call our command without opening the drawing

The broader point of today’s post – other than simply to deliver on step 4, above – is to demonstrate that there are definitely simple options when it comes to architecting and building your own batch-processing tool. It’s quite possible that ScriptPro 2.0 does what you want, out of the box, but in our case it does not: we do not want to load a drawing into the AutoCAD editor to process it, we want to run a custom command to load drawings in side databases in order to process them more quickly.

But as the full source code for ScriptPro 2.0 is available on Autodesk Labs, it’s a simple matter of editing it for our own purposes. I won’t go into great detail on the changes that were needed – most of which were cosmetic in nature – but I will list a few areas:

  • Changed the name of the application from ScriptPro 2.0 to RegAppReport
  • Stripped down the UI of the main dialog
    • Reduced unwanted items from the ribbon (load SCP, for instance)
    • Removed the script selection box and associated code
    • I didn’t bother changing the options dialog, at all, but I did change the load/save of the drawing lists not to include that information
  • Removed the code to open the selected document in the AutoCAD editor
  • Customized the code to call our XRA command – rather than SCRIPT – passing in the DWG we want to process via the command-line
  • Added some code to copy the file placed at C:\RegAppData.xml to the executable location, where our XSLT resides
    • I also decided to back up the previous contents of this file, in case they were needed
    • We could also have specified the XML as an argument to the command, but felt it less disruptive (in terms of changes to the previous implementation) to do it this way
  • We give the option of automatically launching the XML report (rendered to HTML, of course) after processing

It should be noted that the code developed in the previous posts, defining the XRA command, should be built into a plugin and set up to load automatically into AutoCAD at startup or when the XRA command is called (you can, of course, set this up programmatically).

Here are the C# source project and executable files for the modified ScriptPro 2.0 application.

Here’s the application in action…

Our customized ScriptPro 2.0 dialog

With files loaded

During processing 1

During processing 2


And finally the results…

Our RegAppId report

It’s altogether possible to extend this application to actually – even selectively – purge RegAppIds from drawings, but that’s being left as an exercise for the reader.

blog comments powered by Disqus


10 Random Posts