Sei sulla pagina 1di 28

AutoCAD 2013 .

NET API Webcast One Getting Started

About the Presenter

Wayne

Brill

Developer Technical Services Americas

Wayne has been a member of Autodesk Developer Technical services supporting ADN (Autodesk Developer Network) over eleven years. Currently, Wayne provides API support for AutoCAD, Autodesk Inventor, ETO and Vault

2012 Autodesk

Eight Sessions
1. AutoCAD .NET Basics Getting Started Wayne Brill 2. User Interaction - User Input Wayne Brill 3. Database fundamentals Fenton Webb 4. Database Events, PaletteSet Gopinath Taget 5. Dictionaries, Containers - Balaji Ramamoorthy 6. Input PointMonitor - Philippe Leefsma 7. Jigs - Philippe Leefsma 8. User Interface elements - Balaji Ramamoorthy

2012 Autodesk

Course Objective
It

is to understand:
the fundamentals of the AutoCAD .NET API how to teach yourself the AutoCAD .NET API where to get help

What

it is not:

Teach you .NET framework or C# , VB programming language Give you complete of coverage of all API functions

2012 Autodesk

Session 1 Getting Started -Objectives

See

a High level introduction to .NET

Learn

how to create an AutoCAD .NET application

2012 Autodesk

High Level .NET Overview

2012 Autodesk

.NET Framework
VB C++ C# JScript Visual Studio 2008 / 2010

Common Language Specification ASP.NET

Windows Forms

Data and XML

Base Class Library


Common Language Runtime

2012 Autodesk

.NET key components


Common
Interprets

Language Runtime (CLR)

IL code created by the compiler Provides a common execution environment for .NET apps Code that runs in the CLR is Managed code
Framework
Object

Class Library (FCL)

Oriented Collection of re-usable types

2012 Autodesk

CLR Execution Model


Source code Compiler Managed Code (dll or exe) VB vbc.exe C# csc.exe C++ cc.exe

Assembly IL Code

Assembly IL Code

Assembly IL Code

Common Language Runtime


JIT Compiler
Native Code

Operating System Services


2012 Autodesk

.NET Assemblies
Assembly
A IL

Contains:

manifest that describes the assembly code. (Intermediate language)

CLR

ensures:
methods are called in a type safe manner

That

That

other items the assembly needs are available

For
2012 Autodesk

AutoCAD the assembly is a DLL

.NET Debugging Tools

Reflector

Browse .NET assemblies, disassemble, decompile

http://www.reflector.net/ Ildasm

Disassemble .NET assemblies

Location - C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin

Fuslogvw

Diagnose load time problems

Location - C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin

FxCop

Check conformance with Design Guidelines http://msdn.microsoft.com/en-us/library/bb429476(VS.80).aspx Install - C:\Program Files\Microsoft SDKs\Windows\v7.0A\FXCop

2012 Autodesk

Links for .NET

MSDN - Visual Basic Developer Center


http://msdn.microsoft.com/en-us/vbasic/default.aspx

MSDN C# Developer Center


http://msdn.microsoft.com/en-us/vcsharp/default.aspx Training videos, Download Visual Studio express

Microsoft .NET Framework Primer for the Visual Basic Developer

http://msdn.microsoft.com/library/aa730858.aspx#netvbde v01_topic7

2012 Autodesk

How to create an AutoCAD .NET application

2012 Autodesk

Development Environment

Microsoft Visual Studio 2010 (SP1)

AutoCAD 2013

Microsoft Windows 7 Microsoft Windows XP Microsoft Windows vista

2012 Autodesk

AutoCAD .NET API Resources

AutoCAD Developer Center


http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=1911627

AutoCAD .NET 2013 Training

(This is the training to use with this series) (Use this if just getting started with .NET)

My First AutoCAD Plug-in

AutoCAD .NET Users Guide AutoCAD .NET Wizards ObjectARX SDK

NET SDK Samples, Classmap.dwg, Managed Reference Guide

AutoCAD DevBlog
http://adndevblog.typepad.com/autocad/

DevTVs Other Blog posts on AutoCAD .NET

2012 Autodesk

Visual Studio project settings Hello World!

Start with a Class Library application type with DLL output. Add references to AutoCADs managed assemblies

acdbmgd.dll

Database

services and DWG file manipulation (like ObjectDBX) Application specific core logic

acmgd.dll

AutoCAD
accoremgd.dll

AutoCAD

Find them in the AutoCAD install folder (set COPY LOCAL = FALSE)

C:\Program Files\AutoCAD 2013 C:\ObjectARX 2013\inc

2012 Autodesk

How does a plugin for AutoCAD work ?


Reference to AutoCAD DLLs. Use it from ObjectARX INC folder

Code witten in Visual Basic .NET

Project VB.NET

Compile

Assembly (.dll)
2012 Autodesk

Load inside AutoCAD with NETLOAD

Start Hello World Demo project

2012 Autodesk

Namespaces
Add
In In

the namespaces you will be using


VB using the Imports keyword C# use the using keyword

AutoCAD

Namespaces used in most Apps

Autodesk.AutoCAD.ApplicationServices Autodesk.AutoCAD.Runtime Autodesk.AutoCAD.EditorInput

Available

2012 Autodesk

when AutoCAD managed dlls referenced


acmgd.dll, acdbmgd.dll & accoremgd.dll

Add an AutoCAD command using an Attribute

Make a procedure an AutoCAD command by adding an attribute


<CommandMethod("HelloWorld")> _ Public Sub HelloWorld() End Sub

An attribute is added to the metadata for that procedure


CommandMethod or CommandMethodAttribute type accepts several parameters in its constructor such as group name, global and local names, command flags and more (Use the object browser)

2012 Autodesk

AutoCAD Editor Print string to command line

Get the editor object for the active document Call the editors WriteMessage method
<CommandMethod("HelloWorld")> _ Public Sub HelloWorld()

Dim ed As Editor ed = Application.DocumentManager. _ MdiActiveDocument.Editor ed.WriteMessage("Hello World")

End Sub

2012 Autodesk

Recap the steps


1. Start with a Class Library application type (DLL) 2. Add references to AutoCADs managed assemblies

acdbmgd.dll, acmgd.dll & accoremgd.dll

3. Add the namespaces


In VB use Imports keyword, in .C# use the using keyword

4. Add an AutoCAD command using CommandMethod attribute.

5. Create the procedure that will run when the command is run in AutoCAD

using the classes from the AutoCAD managed assemblies.

2012 Autodesk

(acmgd.dll, acdbmdg.dll & accoremgd.dll)

Complete & run Hello World project

2012 Autodesk

Loading .NET assembly


NETLOAD command AUTOLOADER Startup On command invocation Demand Load (Registry) Startup On command invocation On request

From another application

On proxy detection

[HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R19.0\ACADB001:409\Applications\AcLayer] "DESCRIPTION"="AutoCAD Layer Manager" "LOADER"="C:\\Program Files\\AutoCAD 2013\\aclayer.dll" "LOADCTRLS"=dword:0000000e "MANAGED"=dword:00000001 [HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R19.0\ACADB001:409\Applications\AcLayer\Commands] "LAYER"="LAYER [HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R19.0\ACADB001:409\Applications\AcLayer\Groups] "ACLAYER_CMDS"="ACLAYER_CMDS

Use Installers to set these keys!


2012 Autodesk

AutoLoader

AutoCAD loads bundles from %appdata%\Autodesk\ApplicationPlugins

Each bundle has PackageContents.xml

2012 Autodesk

Autodesk Exchange Apps

http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=20143020 DevTV Autoloader Format Explained

2012 Autodesk

How to use the Labs


VB.NET

and C# labs Can be done in two ways


1. Do everything in your own projects Use the provided Doc file for overview Copy and paste the Lab steps 2. Use the Lab Projects Use the provided Doc file for overview Use lab steps in the provided projects

Completed

Labs are provided for reference

2012 Autodesk

Next Week - User Interaction / User Input

Thank You !

2012 Autodesk

Potrebbero piacerti anche