Top Banner
© 2012 Autodesk Using .NET Programming to Create New Possibilities with the AutoCAD® Core Console Augusto Goncalves Senior Developer Consultant
22

Using .NET Programming to Create New Possibilities with

Feb 03, 2022

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Using .NET Programming to Create New Possibilities with

© 2012 Autodesk

Using .NET Programming to Create New

Possibilities with the AutoCAD® Core Console

Augusto Goncalves Senior Developer Consultant

Page 2: Using .NET Programming to Create New Possibilities with

© 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.

Page 3: Using .NET Programming to Create New Possibilities with

© 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

Page 4: Using .NET Programming to Create New Possibilities with

© 2012 Autodesk

Getting started

Page 5: Using .NET Programming to Create New Possibilities with

© 2012 Autodesk

What about you?

Do you know what is AutoCAD Core Console?

Have you used it?

Page 6: Using .NET Programming to Create New Possibilities with

© 2012 Autodesk

Quick demo

Run at C:\Program Files\Autodesk\AutoCAD 2013\accoreconsole.exe

Page 7: Using .NET Programming to Create New Possibilities with

© 2012 Autodesk

Script Pro 2.0

Now supports Console

Download at http://labs.autodesk.com/utilities/scriptpro/

Demonstration

Page 8: Using .NET Programming to Create New Possibilities with

© 2012 Autodesk

First Core Console Sample

Page 9: Using .NET Programming to Create New Possibilities with

© 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

Page 10: Using .NET Programming to Create New Possibilities with

© 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

Page 11: Using .NET Programming to Create New Possibilities with

© 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)

Page 12: Using .NET Programming to Create New Possibilities with

© 2012 Autodesk

Sequential or Parallel?

Page 13: Using .NET Programming to Create New Possibilities with

© 2012 Autodesk

Can we achieve better results?

Start several AcCoreConsole process

In sequence

In parallel: up to 50% faster (empirical result)

Page 14: Using .NET Programming to Create New Possibilities with

© 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

Page 15: Using .NET Programming to Create New Possibilities with

© 2012 Autodesk

And with a 8-core machine

In parallel

In sequence

Better use of

the machine

‘Not responding’

system

Page 16: Using .NET Programming to Create New Possibilities with

© 2012 Autodesk

What about licensing?

Page 17: Using .NET Programming to Create New Possibilities with

© 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, (...)

Page 18: Using .NET Programming to Create New Possibilities with

© 2012 Autodesk

Review the EULA for more information C:\Program Files\Autodesk\AutoCAD 2013\Setup

Page 19: Using .NET Programming to Create New Possibilities with

© 2012 Autodesk

Monitoring a folder

Page 20: Using .NET Programming to Create New Possibilities with

© 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

Page 21: Using .NET Programming to Create New Possibilities with

© 2012 Autodesk

Thank you!

Questions?

Page 22: Using .NET Programming to Create New Possibilities with

© 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.