1.36k likes | 1.41k Views
ObjectARX 2010 Autodesk Developer Technical Services. Autodesk Developer Network (ADN). Access to almost all Autodesk software and SDK’s Including early access to Beta software Members-only website with 1000s of technical articles Unlimited technical support
E N D
Autodesk Developer Network (ADN) • Access to almost all Autodesk software and SDK’s • Including early access to Beta software • Members-only website with 1000s of technical articles • Unlimited technical support • Product direction through conferences • Marketing benefits • Exposure on autodesk.com • Promotional opportunities • 1 to 3 free API training classes • Based on user level www.autodesk.com/joinadn
Developer Technical Services Worldwide Workgroup • Over 25 Specialists World Wide • Virtually 24 hour support, 5 days a week Americas Team • CA, WA, São Paulo European Team • Switzerland, United Kingdom, France, Czech Republic, Russia APac Team • China, Japan, India
Getting Support http://www.autodesk.com/adn-devhelp • Provides access to • On-line knowledgebase • Request submission • Newsgroups • Requests are logged automatically • 1-3 day turnaround • Callbacks as needed • Answers to frequently asked questions are posted in our on-line knowledge base
Course Objective It is to understand: • The fundamentals of ObjectARX • How to teach yourself AutoCAD APIs • Where to get help with afterwards What it is not: • Teach you C++, C#, VB, .NET • Give you complete of coverage of all API functions
Class Agenda Lectures with Labs • Slides give an abstract overview • Labs and my comments give the practical experience Lectures: • Overview of APIs • AutoCAD: Hello.arx – Step 1 + 2 • ObjectDBX: Structure – Step 3 + 4 • ObjectDBX: Extend it! – Step 5 + 6 • AutoCAD: Multi-Document Environment • Notification System – Step 7
Class Schedule Time 10:00 - 5:00 • Lunch 12:00 - 1:00 Day 1 • Overview of APIs • AutoCAD: Hello.arx Day 2 • ObjectDBX: Structure • ObjectDBX: Extend it! Day 3 • AutoCAD: MDE Environment • Notification System
Training Material • ObjectARX.pptx - this presentation • objectarx_2010_win_64_and_32bit.exe - ObjectARX installation file • Inspector.zip - ObjectARX snoop tool
Agenda Overview of APIs AutoCAD: Hello.arx ObjectDBX: Structure ObjectDBX: Extend it! AutoCAD: Multi-Document Environment Notification System
API Overview A general look at APIs • Types of API • Client/Server interaction • Client code AutoCAD’s APIs and IDEs • Implementation • Comparison
What is an API? A contract, it is about responsibilities • Both sides are (or may be) required to • Implement service entry points • Call services properly Code implementing API can be packaged as • Source code modules (.h/.cpp in C++) • Binary • Static library • DLL • EXE
Client EXE, DLL, script, etc. 4 API ATL templates 2 API 1 API Static MFC Library API Win 32 API DLLs API Packaging 1. Source code 2. Static library 3. DLL 4. EXE SomeApp.exe 3
Client/Server Interaction In process • Client/server is in the same process Local • Client/server is on the same machine Remote • Client/server is on the same network
.ARX .ARX ObjectARX APIs AutoCAD The Plug-In Architecture API is implemented by an exe Client is implemented as a dll .DLL .DLL API .EXE
Forms of Client Code SLOW Interpreted code • Source script • AutoLISP in the past Packaged code (p-code) • Pre-processed, semi interpreted code • Compiled Visual LISP AutoCAD.NET • Compiled into IL Compiled code • Processor instructions • ObjectARX FAST
AutoCAD APIs and IDEs Application Programming Interfaces • ObjectARX • .NET Managed API • COM Automation (VB, Java, Delphi, etc.) • AutoLISP Integrated Development Environments in AutoCAD • Visual LISP • Visual Basic, Applications Edition (VBA) (Visual Studio outside AutoCAD)
API Implementation I AutoCAD Input acquisition Input driver 2D graphics cache (WHIP!) Plotter driver PlotHDI ObjectDBX 3D graphics cache Display driver HEIDI • ObjectARX SDK (free, http://www.autodesk.com/objectarx) • RealDWG (licensed, http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=770257) • Plot DDK (licensed, http://www.autodesk.com/adn-devhelp) • HEIDI DDK (licensed, http://www.autodesk.com/heidi) • Wintab API (free) dwg
API Implementation II .NET COM Client (VB, Java, Delphi) VBA script Lisp script Acdbmgd.dll Acmgd.dll vl.arx acvba.arx axdb.dll ObjectARX APIs COM AutoCAD
How to Store Your Data in AutoCAD Different Programming Techniques Data Container Performance Chart Time in seconds
How to Store Your Data in AutoCAD Different Programming Techniques Data Container Performance Chart Time in seconds
How to Store Your Data in AutoCAD Different Programming Techniques Data Container Performance Chart Time in seconds
API Comparison Summary Speed • ObjectARX, .NET is close second, VBA also though obsolete Coverage • ObjectARX, .NET everything except custom objects Ease of use • .NET, VBA Learning curve • .NET, VBA
Agenda Overview of APIs AutoCAD: Hello.arx ObjectDBX: Structure ObjectDBX: Extend it! AutoCAD: Multi-Document Environment Notification System
AutoCAD: Hello.arx ObjectARX • What it is • Where to get it ObjectARX applications • Structure • Loading • Memory management Creating commands • Command mechanism • Prompting for user input ObjectARX Wizards
What is ObjectARX? AutoCAD Runtime eXtension • A DLL plug-in model • A set of Object Oriented C++ libraries • A framework A framework? • More than just a toolkit • Specialized objects can be plugged back into the system • Custom entities • Reactors • ...
What can I do with ObjectARX? Modify and extend the drawing database • Create/modify/erase objects • Create new types of objects Modify AutoCAD’s user interface • Commands • Toolbars/dialogs • Properties Window • Design Center • Display system Monitor/Modify AutoCAD’s standard behavior • Event notifications • Input point acquisition
Getting the ObjectARX SDK Download - Free On Autodesk public web site Developer Center - ObjectARX (http://usa.autodesk.com/adsk/servlet/index?id=773204&siteID=123112) Or Search for ObjectARX on http://www.autodesk.com/
Binary compatibility ObjectARX 2010 • AutoCAD 2010 • Binary incompatible with earlier releases ObjectARX 2009 • AutoCAD 2009 ObjectARX 2008 • AutoCAD 2008 and 2009 ObjectARX 2007 • AutoCAD 2007, 2008 and 2009 • Binary incompatible with earlier releases ObjectARX 2006, 2005,2004… • Not supported, as well as AutoCAD versions older than 2007
Development Environment For ObjectARX development • Microsoft Visual Studio 2008 SP1 ObjectARX 2010 SDK Microsoft Windows 2000 SP2 or better
ObjectARX SDK Contents What comes with the SDK • Libraries and Header Files • Documentation • Samples • Utilities
Main Libraries - I AcRx Object and Class Management (rxapi.lib) AcEd AutoCAD Editor Facilities (acedapi.lib) AcDb AutoCAD Database (acdb18.lib) AcGi AutoCAD Graphics Interface (acgiapi.lib) AcGe AutoCAD Geometry Library (acge18.lib) 32- and 64-bit versions: C:\ObjectARX 2010\lib-win32 and C:\ObjectARX 2010\lib-x64
Main Libraries - II AcUi/AdUi MFC Extension Library (adui18.lib acui18.lib) Automation (axdb.lib oleaprot.lib) ads_ Function Set (acad.lib) Static Linking Memory Management (rxheap.lib)
Utilities AutoCAD Facet Modeler (aecmodeler60.lib) AutoCAD Boundary Representation (acbr18.lib, acgex19.lib) ObjectARX Wizard (<your path>\ObjectARX 2010\utils\ObjARXWiz\ArxWizards.msi) ATIL - Raster graphics Teefy - Converting existing applications to Unicode string handling
On-line Documentation Found in ObjectARX\docs • ObjectARX Documentation (arxdoc.chm) • ObjectARX Developers Guide (arxdev.chm) • Reference Manual (arxref.chm) • Managed Class Reference Guide (arxmgd.chm) • What's New (arxwhnew.chm) • Migration Guide (arxmgr.chm) • Interoperability Guide (arxiop.chm) • ObjectARX Readme (readarx.chm) ObjectARX Training Material and Labs (ObjectARX\arxlabs\ObjectARXLabs.chm)
Samples The ObjectARX SDK comes with a number of code samples organized into sub-categories: • ObjectARX\Samples • COM • Database • DotNet • Editor • Entity • Graphics • Misc • Reactors • PolySamp and ArxDbg Also see Knowledgebase on the ADN website.
acrxEntryPoint • acrxGetApiVersion .ARX .ARX ObjectARX APIs AutoCAD .ARX = .DLL + 2 exported functions .DLL .DLL API .EXE
Loading ObjectARX Applications I Loaded by the user • ARX & APPLOAD commands • Drag & Drop Demand loaded • Startup • acad.rx file • Registry • (arxload) in acad.lsp • On command invocation • Registry • On request • From another application • On proxy detection • Registry Live Enablers (see PolySamp)
3. 5. 4. 6. 1. 2. Loading ObjectARX Applications II AutoCAD .ARX Rxapi.lib CRT Operating System 1. LoadLibrary 2. _DllMainCRTStartup (see MSDN for info) 3. CRT_INIT (constructs global class vars) 4. DllMain (see MSDN for info) 5. acrxGetApiVersion 6. acrxEntryPoint
3. 2. Piece of Memory CRASH! 1. Wrong ARX Memory Management AutoCAD/ObjectDBX MSVCRT.DLL .ARX MSVCRTD.DLL 1. .ARX allocates memory from debug heap 2. .ARX passes allocated memory to AutoCAD 3. AutoCAD de-allocates it with release ‘delete’… CRASH
1. .ARX allocates memory from release heap 2. .ARX passes allocated memory to AutoCAD 3. AutoCAD de-allocates it with release ‘delete’… OK 3. Piece of Memory 2. 1. Correct ARX Memory Management I AutoCAD/ObjectDBX MSVCRT.DLL .ARX
1. .ARX allocates memory via rxheap.lib 2. AutoCAD allocates memory on release heap 3. .ARX passes memory to AutoCAD 4. AutoCAD de-allocates it with release ‘delete’… OK 2. 4. Piece of Memory 1. 3. Correct ARX Memory Management II AutoCAD/ObjectDBX MSVCRT.DLL .ARX Rxheap.lib Libcmt.lib
Getting Started Visual C++ 9.0 (.NET) AutoCAD 2010 ObjectARX 2010 ArxDbg \ObjectARX 2010\samples\database\ARXDBG Dependency Walker www.dependencywalker.com or C:\Program Files\Microsoft Visual Studio 9\Common7\Tools\bin\depends.exe Process Monitorwww.sysinternals.com
1. 4. 5. 2, 3. 6. AcEdCommand Command Mechanism I .ARX AcEdCommandStack Callback function AutoCAD 1. Add command 2. Create command object 3. Parameterize it 4. User types command name 5. Lookup command object 6. Call callback function
Command Mechanism II Removing commands is as important as adding them Command names can clash • Commands belong to groups Command groups must be unique • Registered Developer Symbol (RDS) • Search for “Registered Developer Symbol” takes you to http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=1075006
Lab - Step 1 Setup your first .ARX
Prompting for User Input AcEd functions • String, number acquisition acedGetString(), acedGetInt() • Point, angle acquisition acedGetPoint(), acedGetAngle() • Entity selection acedEntSel() Full range of Win32 controls
ObjectARX 2010 Wizards Application Wizard • ObjectARX\utils\ObjARXWiz\ArxWizards.msi • COM Wrapper Wizard • Custom Object Wizard • Reactors Class Wizard etc. Visual Studio Add-In • ObjectARX Commands • Autodesk Class Explorer etc.
Lab - Step 2 Play around with user input functions
Agenda Overview of APIs AutoCAD: Hello.arx ObjectDBX: Structure ObjectDBX: Extend it! AutoCAD: Multi-Document Environment Notification System