© 2012 Autodesk Using .NET Programming to Create New Possibilities with the AutoCAD® Core Console Augusto Goncalves Senior Developer Consultant
© 2012 Autodesk
Using .NET Programming to Create New
Possibilities with the AutoCAD® Core Console
Augusto Goncalves Senior Developer Consultant
© 2012 Autodesk
Class Summary
Starting with AutoCAD 2013, it is now possible use AutoCAD software
from the Core Console, which can help us automate tasks with a more
stable and controllable headless AutoCAD. This class will explore how to
use and integrate the Core Console using .NET programming. Prior
knowledge of .NET programming and the AutoCAD API are required.
© 2012 Autodesk
Learning Objectives
At the end of this class, you will be able to:
Use the AutoCAD Console with not programming skills
Create custom commands for the console
Speed up with threads
Integrate with Windows APIs
© 2012 Autodesk
Script Pro 2.0
Now supports Console
Download at http://labs.autodesk.com/utilities/scriptpro/
Demonstration
© 2012 Autodesk
Using .bat and .scr files
No complicated programming required
Write a .bat file that will launch AutoCAD Console and process files
FOR %%f IN (c:\DwgFolder\*.dwg) DO "C:\Program Files\Autodesk\AutoCAD
2013\accoreconsole.exe" /i "%%f" /s "c:\MyScript.scr" /l en-US
Simple and effective
Demonstration
© 2012 Autodesk
Using with plug-ins
Create plug-in with no interface
Launch and load the plug-in
NETLOAD, APPLOAD, VBALOAD
Run the custom command
© 2012 Autodesk
Demonstration with .NET
Using .NET Process object
UseShellExecute = false and CreateNoWindow = true avoid console ‘UI’
Capture the console output
RedirectStandardOutput = true to capture the outpu
StandardOutput contains the text data
Plug-ins for the console can only use AcMgd and AcCoreMgd
DO NOT use AcMgd (UI)
© 2012 Autodesk
Can we achieve better results?
Start several AcCoreConsole process
In sequence
In parallel: up to 50% faster (empirical result)
© 2012 Autodesk
Demonstration
Process files in sequence and parallel
Sample project Threads
Important: an AutoCAD process is not thread safe
No multithread inside the same accoreconsole
© 2012 Autodesk
And with a 8-core machine
In parallel
In sequence
Better use of
the machine
‘Not responding’
system
© 2012 Autodesk
AutoCAD 2013 License and Services Agreement
2. License Limitations/Prohibitions
2.1 Limitations and Exclusions.
2.1.1 No License Granted/Unauthorized Activities. (…) (g) except as otherwise expressly provided with respect to a specific License Type, to Install or Access or allow the Installation of or Access to the Autodesk Materials over the Internet or other non-local network, including, without limitation, use in connection with a wide area network (WAN), virtual private network (VPN), virtualization, Web hosting, time-sharing, service bureau, software as a service, cloud or other service or technology, (...)
© 2012 Autodesk
Process files copied/moved to a folder
Using FileSystemWatcher .NET API
Will process in parallel
One for each file affected
May ‘freeze’ not machine during the process
Demonstration
Sample project Monitor
© 2012 Autodesk
Autodesk, AutoCAD* [*if/when mentioned in the pertinent material, followed by an alphabetical list of all other trademarks mentioned in the material] are registered trademarks or trademarks of Autodesk, Inc., and/or its subsidiaries and/or affiliates in the USA and/or other countries. All other brand names, product names, or trademarks belong to their respective holders. Autodesk reserves the right to alter product and
services offerings, and specifications and pricing at any time without notice, and is not responsible for typographical or graphical errors that may appear in this document. © 2012 Autodesk, Inc. All rights reserved.