230 likes | 328 Views
CP305-3 C# .NET Command School. Doug Goforth Software Development: National MultiTech LTD, CadPLUS Products. Doug Goforth - Real code examples you can use - Prompting the Autodesk way - Getxxx functions in .NET - Setting and getting keyword responses Creating LISP Function in .NET
E N D
CP305-3 C# .NET Command School Doug Goforth Software Development: National MultiTech LTD, CadPLUS Products
Doug Goforth - Real code examples you can use - Prompting the Autodesk way - Getxxx functions in .NET - Setting and getting keyword responses Creating LISP Function in .NET Deployment .NET Command School
Please quiet your cell phones and pagers. If your have to leave, please do so quietly. Please hold questions until the end. If your eat candy with noisy wrappers please share with those around you Before We Start…
About Doug and the Stuff He Does Over 20 years of CAD solution experience for Facilities. Member of Autodesk Developer Network Developer/Programmer for CadPLUS Products written in .NET for AutoCAD 2005/2006/2007/2008/2009/2010… Developed client software, strategy, and procedures for200 million sf FM solution including MapGuide deployment. Developer for a plethora of programs in AutoLISP, VB6, .NET, MapGuide, WebSphere, Java, ASP, JSP (and a smattering of ObjectARX)
About You and the Stuff You Do VB programmers? C# programmers? AutoLISP programmers? Programmed in ObjectARX? Only job is programming for AutoCAD? New to .NET programming for AutoCAD? Have written installation programs for AutoCAD apps?
Giving Your Command Some Style • Why Emulate the AutoCAD Style? • AutoCAD is consistent in their presentation of command prompts • Users are already familiar with the AutoCAD Style • Familiar prompting will promote user-friendliness • User-friendly programmers are loved and adored by all
Prompts We Know and Love • Select objects: • Specify a point: • Specify first point: • Specify height <0.200>: • Specify base point or [Displacement] <Displacement>: • Enter block name or [?]: • Enter an option [Next/Previous/Go/eXit] <N>:
All Prompts are Created Equal Command: MYCOMMAND Please do something now [First/Second]<F>:
User Responses Type something, text/keyword Select something Press ENTER Press ESC
COM Pros • Can be used to interact with AutoCAD from a standalone exe Cons • Prompt strings must be constructed entirely by the programmer Managed Pros • Can be compiled in an AutoCAD aware assembly • Programming for prompts can use methods and intellisense provided in the API Cons • Vast API for prompting cannot be accessed through COM COM vs. Managed Code
Basic Project Setup COMNot necessary for managed .NET code, but useful for accessing AutoCAD from other Windows executables. • AutoCAD 2010 Type Library (AutoCAD) • AutoCAD/ObjectDBX Common 18.0 Type Library (AXDBLib) Managed DLLs (referenced from your ACAD folder) • acdbmgd.dll (autocad-database-managed) • acmgd.dll (autocad-managed)
Managed Code Essentials Namespaces • Autodesk.AutoCAD.Runtime • Autodesk.AutoCAD.EditorInput • Autodesk.AutoCAD.ApplicationServices • Autodesk.AutoCAD.DatabaseServices • DbTransMan = Autodesk.AutoCAD.DatabaseServices.TransactionManager • Autodesk.AutoCAD.Geometry
Managed Code Essentials Defining a Command Autodesk.AutoCAD.Runtime.CommandMethod • Used to make your command visible to AutoCAD • Compile to a dll • Load into ACAD with the NETLOAD command • May also be demandloaded in the registry
Managed Code Essentials Writing to the Command: Line MdiActiveDocument.Editor • Gives you a way to interact with the AutoCAD Editor • Used to write your prompt to the Command: line
Managed Code Essentials Prompt Classes and Methods Prompt OptionAutodesk.AutoCAD.EditorInput.PromptxxxOptions • Gives you a way to compose the prompt Prompt ResultAutodesk.AutoCAD.EditorInput.PromptxxxResult • Tells you how the user responded to your prompt
Uses [LispFunction] Class attribute Arguments are passed as a ResultBuffer object Argument order can be determined by casting the ResultBuffer to an Array object Argument types can be determined by testing the type of the value property of the TypedValue object in the ResultBuffer .NET LISP Functions
Demandloading Your Application Registry Making AutoCAD “aware” of your application What is it called? What is the assembly file name? Where is it located? How should it be loaded? On startup, on object load, etc? Specified as managed code? What is the command name?
REG File ComSchool.reg Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R18.0\ACAD-8001:409\Applications\AUNetLoad] "DESCRIPTION"="AU 2010 Demandload Example" "LOADER"="C:\\Program Files\\AU2009\\ComSchool.dll" "LOADCTRLS"=dword:00000002 "MANAGED"=dword:00000001 [HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R18.0\ACAD-8001:409\Applications\AUNetLoad\Commands] "AUNetLoad"="AUText" [HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R18.0\ACAD-8001:409\Applications\AUNetLoad\Groups] "AUNetMan"="AUNetMan"
Product ID Registry Keys AutoCAD 2010 [HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R18.0\ACAD-8001:409\Applications\AUNetLoad] ..\R18.0\ACAD-8001:409 = AutoCAD ..\R18.0\ACAD-8002:409 = Map ..\R18.0\ACAD-8003:409 = Mechanical Desktop for AIS ..\R18.0\ACAD-8004:409 = Architectural Desktop ..\R18.0\ACAD-8005:409 = AutoCAD Mechanical ..\R18.0\ACAD-8006:409 = Building Systems ..\R18.0\ACAD-8007:409 = AutoCAD Electrical ..\R18.0\ACAD-8008:409 = Land Desktop ..\R18.0\ACAD-8009:409 = AutoCAD LT ..\R18.0\AOEM-8001:409 = AutoCAD OEM ..\R18.0\ACAD-8013:409 = Mechanical Desktop for AIP ..\R18.0\ACAD-8022:409 = Autodesk Utility Design ..\R18.0\ACAD-8000:409 = Autodesk Civil 3D ..\R18.0\ACAD-8012:409 = Architectural Desktop w/Raster Design Product Name Product ID ACAD Version Language------------ 409=English 407=German 404=Chinese Etc. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_61df.asp
CP314-3 C# .NET Command School Doug Goforth doug.goforth@nationalmultitech.com Have a great AU! Thank You!