ARES Commander supports three API sets that you can use independently. Now here we’ll going to discuss about CFx. NET(.NET ARES) and listed it’s differences with .NET Classic API's coding.
.NET Classic API
ARES COM API
CFx .NET (SWIG generated .NET API version of ARES C++ SDK)
Here We differentiate between .NET Classic and .NET ARES.
API | .NET Classic API | CFx .NET (.NET ARES) |
---|---|---|
Assembly Names | TD_Mgd_x.xx_xx.dll FxCoreMgd_x.xx_xx.dll | ArgonMGD.dll TD_SwigCoreMgd.dll TD_SwigDbMgd.dll TG_SwigDbMgd.dll TD_Mgd_x.xx_xx.dll |
Nature of Plugin | In-process | In-process |
Loading Mechanism | Use the NETLOAD command | Use the NETLOAD command |
Migration to AutoCAD | Can Migrate to AutoCAD | Can’t Migrate to AutoCAD |
Access Document | Document document = Teigha.ApplicationServices.Application.DocumentManager.MdiActiveDocument; | CFxDocument pFxDocument = PCADGlobals.FXAPI().GetFxDocument(); |
Access Database | Database db = document.Database; | CFxDatabase pFxDatabase = pFxDocument.GetFxDatabase(); |
Prompting For User Input | PromptIntegerOptions op = new PromptIntegerOptions("Input a positive integer"); | CFxUserIO pFxUserIO = pFxDocument.GetFxUserIO(); |
Lisp Function Creation | Possible to create Lisp Functions. Using | Cannot create Lisp Functions. |
Creating a .NET Classic Plugin:
Create a new .NET ARES project using the Visual Studio project creation Wizard( **minimum requirement .NET Framework v4.5)
From Solution Explore, add references of
ArgonMGD.dll
TD_SwigCoreMgd.dllTD_SwigDbMgd.dll
TG_SwigDbMgd.dll
TD_Mgd_x.xx_xx.dll from the ARES Commander installation folder.
You can see all available NameSpaces, Classes, Methods, and Properties in each assembly in the Object Browser.
Rename Class1.cs to PluginCommands.cs. This changes the class Class1 to class PluginCommands, as in the following example.
Defining a command uses Teigha.Runtime namespace to access CommandMethod method attribute and adds a method, such as AnyFunctionName that has this attribute. The following example defines the MySampleCommand command which you can run later in ARES Commander, from the command prompt.
You can define all types of in-process plugin using a similar procedure.Build the sample project to generate PluginCommands.dll or <YourProjectName.dll>.
Start ARES Commander and type NETLOAD at the command prompt. Next, browse and load the plugin dll (PluginCommands.dll).
The command window displays a confirmation message.
7. Run MySampleCommand, which executes the AnyFunctionName method.
Accessing Documents
You can access the Document Manager from the application object.
The Document Manager provides properties and methods that let you perform the following:
Access the active document
CFxDocument doc = PCADGlobals.GetFxSystemServices().GetFxDocumentManager().GetActiveDocument();
Add a new document
CFxString templateStr = new CFxString("newTemplate"); CFxDocument doc = PCADGlobals.GetFxSystemServices().GetFxDocumentManager().NewDocument(templateStr);
Open existing drawings.
Prompting for User Input
The CFxUserIO class controls the user input. All related classes for prompting on the command window are available in PCAD_DOT_NET.CFxUserIO namespace.
CFxDocument Doc = PCADGlobals.FXAPI().GetFxDocument(); CFxDatabase pDB = Doc.GetFxDatabase(); CFxUserIO UserIO = Doc.GetFxUserIO(); if (UserIO == null) return; CFxString prompt = UserIO.GetPrompt(new CFxString("Specify center point for circle or")); OdGePoint3d centerPoint = new OdGePoint3d(); double radius = 5.0; int iResult = UserIO.GetPoint(prompt, new OdGePoint3d(), null, centerPoint); if (iResult == PCADGlobals.RTNORM) { using (OdDbCircle circle = OdDbCircle.createObject()) { circle.setDatabaseDefaults(pDB, true); circle.setThickness(pDB.getTHICKNESS()); circle.setCenter(centerPoint); circle.setRadius(radius); OdDbBlockTableRecord pBTR = (OdDbBlockTableRecord)pDB.GetActiveBlockId().openObject(Teigha.TD.OpenMode.kForWrite); pBTR.appendOdDbEntity(circle); } }