34
AutoCAD® .NET: Using .NET With Your LISP Applications Wayne Brill API Consultant - Autodesk

autolisp

Embed Size (px)

DESCRIPTION

cad

Citation preview

AutoCAD® .NET: Using .NET With Your LISP ApplicationsWayne BrillAPI Consultant - Autodesk

About the Presenter

Wayne Brill Developer Technical Services Americas Autodesk, Inc.

Wayne has been a member of Autodesk Developer Technical services supporting ADN (Autodesk Developer Network) for nine years. Currently, Wayne provides API support for Autodesk Inventor®, AutoCAD, AutoCAD® Mechanical, AutoCAD OEM, and RealDWG™.

Areas of focus

AutoCAD .NET brief overview

Interface for AutoLISP and AutoCAD .NET API

Using .NET Forms from AutoLISP

.NET API to access new features not available from AutoLISP

P/Invoke to access API’s not wrapped by the .NET API

AutoCAD .NET - brief overview

AutoCAD .NET

Managed Assemblies wrap ObjectARX

Reference acdbmgd.dll and acmgd.dllSet Copylocal to false when debugging or NETLOAD fails

Namespaces

AutoCAD .NET

ObjectARX Wizard will install wizards for creating VB.NET and C# applications in VS 2008

ObjectBrowser will help to explore the available classes

Use transactions to open objects A transaction can be committed, aborted or disposed. Call dispose in finally block (in VB)

or use the using keyword

AutoCAD .NET

Try Catch block

AutoCAD .NET

Add Registry key if Breakpoint error debugging & starting Visual LISP editor.

Use Appload Startup Suite to automatically load lisp files. (or acad.lsp)

Use NETLOAD command to load .NET applications Also possible to set up registry to demand load

Interface for AutoLISP and .NET

LispFunction attribute

Defines a .NET function that can be called by a LISP function

Name space

Similar behavior to the CommandMethod attribute

LispFunction Attribute & Signature

Demo

Create a New Project and call a .NET function from AutoLISP

ResultBuffer

Autodesk.AutoCAD.DatabaseServices.ResultBuffer

ResultBuffer contains descriptions and a values Data pairs

Prepopulate the ResultBuffer Pass an array of TypedValue objects to the constructor

Construct an empty ResultBufferCall the ResultBuffer::Add() method to add a new TypedValue

TypedValue

TypedValue.TypeCode is a 16-bit integer value Indicates the data type TypedValue.Value

value must be the type indicated by TypeCode

Use LispDataType to define value types

LispDataType

Defines identifiers that represent the data types passed through AutoLISP ResultBuffer arguments.

LispDataType Fields_atom,Nil,DottedPair, ListEnd, ListBegin Point3d, Orientation, ObjectId, Angle Point2d, None, SelectionSet, Void Int32,Int16, Double, Text

Provides Result Type Codes Defined by ObjectARX

AutoLISP - .NET interaction demo

Pass in an argument

Pass arguments to a .NET function change them and return the data to the LISP function

Return a SelectionSet

Return a selected entity

Using .NET Forms from AutoLISP

Use a .NET Form to get input for LISP

Add a form to the project with the controls you need to gather the input from the user

Create a LispFunction that will display the form

When the user dismisses the form get the input the user entered on the form

Send the input the user entered back to the calling function in a ResultBuffer

Use a .NET form with AutoLISP demo

.NET API to access new features not available from AutoLISP

New API functionality

ObjectARX and AutoCAD .NET get the priority for new functionality

AutoLISP and COM are usually not updated with new features

Need to migrate applications to these new languages or find a way to use these new features from AutoLISP.

Newer functionality using LISP & .NET

Layer Viewport overrides and Viewport annotation scaling.

ObjectARX and AutoCAD .NET allow you to programmatically set these overrides

COM and AutoLISP do not support this (unable to automate using command function)

Use AutoCAD .NET to overcome AutoLISP limitation - Demo

AutoLISP & .NET to set layer viewport overrides AutoLISP & .NET to set the viewport annotation scale

Platform Invoke to access API’s not wrapped by the AutoCAD .NET API

Three useful ObjectARX functions

Use Platform Invoke to use these functions

acedPutSym set AutoLISP variables

acedGetSym get AutoLISP variables

acedInvoke Run AutoLISP functions from .NET

Platform Invoke

DllImport Available from InteropServices

acedGetSym

P/Invoke ObjectARX functions in AutoCAD .NET for AutoLISP - demo

Use P/Invoke to get and set LISP variables.

Use P/Invoke to run an AutoLISP function.

Summary

AutoCAD .NET Basics Acmgd.dll, Acdbmgd.dll, Namespaces, Try Catch, Transactions

Interface for AutoLISP and .NET LispFunction, ResultBuffer, TypedValue, LispDataType

Using .NET Forms from LISPGather the input from the user, Send it back to calling function using a ResultBuffer

NET API to access new features not available in AutoLISP

P/Invoke to access API’s not wrapped by the .NET API

AutoCAD .NET Resources ObjectARX 2010 SDK - arxmgd.chm

AutoCAD .NET Developer's Guide

AutoCAD Developer Center - download training labs http://www.autodesk.com/developautocad

AutoCAD .NET Training (classroom) http://www.autodesk.com/apitraining

Through the Interface blog - Site focuses on .NET http://blogs.autodesk.com/through-the-interface

Information about Autodesk Developer Network www.autodesk.com/joinadn

Autodesk Developer Network

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

DevLab

San Francisco, USA Feb 1-5, 2010 Farnborough, UK Feb 8-12, 2010 Munich, Germany June 7-11, 2010 Other countries TBD

www.autodesk.com/apitraining > Schedule There is a link where you can register:

Q & A

Thank You