These plug-ins There are of two types of ActiveX/COM plugins:
- Out-Process: Runs as a separate .exe file.
- In-Process:Using Runs using the NETLOAD command.
Out-Process Active/COM Plugins
- Create a new C# or VB.NET
...
- project using the Visual Studio project Wizard( **minimum requirement .NET Framework v4.5).
One can either create Windows Form Application, Console Application or Class Library.
...
- From Solution Explorer, add references of OdaX_x.xx_xx*.dll and ARESC.exe
...
- from ARES Commander installation folder.
...
- You can add references by searching PCAD_AC_X and PCAD_DB_X from COM Assemblies.
...
...
- You can see the available NameSpaces, Class Methods, and Properties in each assembly using Object Browser.
Rename Program.cs to PluginCommands
...
. This will change class Program to class PluginCommands
...
as in the following example.
Code Block language c# theme RDark firstline 1 linenumbers true namespace SamplePlugins { class PluginCommands { static void Main(string[] args) { } } }
- There two ways to work with out process
...
- :
- Create a new Instance
...
- Attach with already running application
...
- Creating an Instance of AcadApplication. Use PCAD_AC_X .
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
using PCAD_AC_X; using System.Runtime.InteropServices; namespace SamplePlugins { class PluginCommands { static void Main(string[] args) { AcadApplication app = (PCAD_AC_X.AcadApplication)Marshal.GetActiveObject("PCAD_AC_X.AcadApplication"); } } } |
Accessing Documents and Active Documents
- From application object one can access collection of documents or active documents and Preferences.
- Following Code iterates through the document collection.
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
IAcadPreferencesDisplay AcadPref; AcadPref = app.Preferences.Display; int Size = AcadPref.CursorSize; |
Prompting For User
- Utility functions that allow you to request input from the user or perform geometric calculations.
- Utility can be accessed through ActiveDocument object. There are various functions in utility that prompts user to input. for example to input integer there is GetInteger(). Like this for prompting Angle, Distance, AngleFromAxis, Keyword, etc there is a corresponding method.
- See following code for the reference.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
int promptInteger; //With prompting to user promptInteger = app.ActiveDocument.Utility.GetInteger("Enter an integer") //Without prompting to user promptInteger = app.ActiveDocument.Utility.GetInteger(); |
In-Process
- Create a new C# or VB.NET project using Visual Studio project Wizard( **minimum requirement .NET Framework v4.5)
...
- Rest procedure for accessing various ActiveX/COM objects and collections is same.
Migration of AutoCAD® ActiveX PlugIn Application to ARES Commander
The ActiveX/COM applications running on AutoCAD® platform can be easily migrated to ARES Commander by making minimal changes.
...