There are two types of ActiveX/COM plugins:
...
- 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 For reference, see the 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)
...
- From Solution Explorer, add references of OdaX_x.xx_xx*.dll, ARESC.exe and TD_Mgd_x.xx_xx.dll
...
- from ARES Commander installation folder.
...
- 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 ActiveXCOMSample { public class PluginCommands { } }
Defining a command
...
uses Runtime namespace to access CommandMethod
...
attribute
...
and add a method
...
with this attribute.
...
See AnyFunctionName() in the following example.
The following example defines the MySampleCommand command.Code Block language c# theme RDark firstline 1 linenumbers true using Teigha.Runtime; namespace ActiveXCOMSample { public class PluginCommands { [CommandMethod("MySampleCommand")] public void AnyFunctionName() { } } }
...
Using a similar procedure you can create all types of in-process
...
plugin.
...
- Building the sample project
...
- generates dll or <YourProjectName.dll>
- Run ARES and type NETLOAD on command line it will prompt to load the plug-in dll, browse PluginCommands.dll and Load, message of successful loading will appear on command line.
- Run MySampleCommand AnyFunctionName method will be executedStart ARES Commander.
- Type NETLOAD at the command prompt and press Enter. Navigate to PluginCommands.dll and load it. The command window displays a confirmation message.
- Run MySampleCommand which will execute the AnyFunctionName method.
- Now instead of creating instance of AcadApplication, we will use GetActiveObject method, because in this case Ares will already be running.
- For Marshal use System.Runtime.InteropServices
...
- Rest procedure for accessing various ActiveX/COM objects and collections is same.
Migration of AutoCAD® ActiveX PlugIn Application to ARES Commander
...