09.08.2015 Views

Augusto Goncalves - Autodesk

Augusto Goncalves - Autodesk

Augusto Goncalves - Autodesk

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Using .NET Programming to Create NewPossibilities with the AutoCAD® Core Console<strong>Augusto</strong> <strong>Goncalves</strong>Senior Developer Consultant© 2012 <strong>Autodesk</strong>


Class SummaryStarting with AutoCAD 2013, it is now possible use AutoCAD softwarefrom the Core Console, which can help us automate tasks with a morestable and controllable headless AutoCAD. This class will explore how touse and integrate the Core Console using .NET programming. Priorknowledge of .NET programming and the AutoCAD API are required.© 2012 <strong>Autodesk</strong>


Learning ObjectivesAt 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 <strong>Autodesk</strong>


Getting started© 2012 <strong>Autodesk</strong>


What about you?• Do you know what is AutoCAD Core Console?• Have you used it?© 2012 <strong>Autodesk</strong>


Quick demo• Run at C:\Program Files\<strong>Autodesk</strong>\AutoCAD 2013\accoreconsole.exe© 2012 <strong>Autodesk</strong>


Script Pro 2.0• Now supports Console• Download at http://labs.autodesk.com/utilities/scriptpro/• Demonstration© 2012 <strong>Autodesk</strong>


First Core Console Sample© 2012 <strong>Autodesk</strong>


Using .bat and .scr files• No complicated programming required• Write a .bat file that will launch AutoCAD Console and process filesFOR %%f IN (c:\DwgFolder\*.dwg) DO "C:\Program Files\<strong>Autodesk</strong>\AutoCAD2013\accoreconsole.exe" /i "%%f" /s "c:\MyScript.scr" /l en-US• Simple and effective• Demonstration© 2012 <strong>Autodesk</strong>


Using with plug-ins• Create plug-in with no interface• Launch and load the plug-in• NETLOAD, APPLOAD, VBALOAD• Run the custom command© 2012 <strong>Autodesk</strong>


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 <strong>Autodesk</strong>


Sequential or Parallel?© 2012 <strong>Autodesk</strong>


Can we achieve better results?• Start several AcCoreConsole process• In sequence• In parallel: up to 50% faster (empirical result)© 2012 <strong>Autodesk</strong>


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 <strong>Autodesk</strong>


And with a 8-core machineIn sequenceIn parallelBetter use ofthe machine‘Not responding’system© 2012 <strong>Autodesk</strong>


What about licensing?© 2012 <strong>Autodesk</strong>


AutoCAD 2013 License and Services Agreement2. License Limitations/Prohibitions2.1 Limitations and Exclusions.2.1.1 No License Granted/Unauthorized Activities.(…)(g) except as otherwise expressly provided with respect to a specificLicense Type, to Install or Access or allow the Installation of or Accessto the <strong>Autodesk</strong> 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, timesharing,service bureau, software as a service, cloud or other service ortechnology,(...)© 2012 <strong>Autodesk</strong>


Review the EULA for more informationC:\Program Files\<strong>Autodesk</strong>\AutoCAD 2013\Setup© 2012 <strong>Autodesk</strong>


Monitoring a folder© 2012 <strong>Autodesk</strong>


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 <strong>Autodesk</strong>


Thank you!Questions?© 2012 <strong>Autodesk</strong>


<strong>Autodesk</strong>, 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 <strong>Autodesk</strong>, 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. <strong>Autodesk</strong> reserves the right to alter product andservices 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 <strong>Autodesk</strong>, Inc. All rights reserved.© 2012 <strong>Autodesk</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!