Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

There are two types of ActiveX/COM plugins:

...

  1. Create a new C#  or VB.NET project using the Visual Studio project Wizard( **minimum requirement .NET Framework v4.5.28).
    One can either create Windows Form Application, Console Application, or Class Library.

  2. From Solution Explorer, add references to OdaX_xx.x.xx_xx*.dll dll and ARESC.exe from ARES Commander installation folder.

  3. You can add references by searching PCAD_AC_X and PCAD_DB_X from COM Assemblies.

  4. You can see the available NameSpaces, Class Methods, and Properties in each assembly using Object Browser.

  5. Rename Program.cs to PluginCommands. This changes class Program to class PluginCommands as in the following example.

    Code Block
    languagec#
    themeRDark
    firstline1
    linenumberstrue
    namespace SamplePlugins
    {
    	class PluginCommands
    	{
    		static void Main(string[] args)
    		{
    		}
    	}
    }


  6. There are two ways to work with an out-process plugin:
    • Create a new Instance
    • Attach the debugger while the application is running

  7. To create an Instance of AcadApplication, use PCAD_AC_X.
    This call starts ARES Commander directly.

    Code Block
    languagec#
    themeRDark
    firstline1
    linenumberstrue
    using PCAD_AC_X;
    
    namespace SamplePlugins
    {
    	class PluginCommands
    	{
    		static void Main(string[] args)
    		{
    			Application app = new AcadApplication();
    		}
    	}
    }

    If ARES Commander is already running, use a version dependent ProgIDs or an independent one as in the following example.
    For Marshal, use System.Runtime.InteropServices.

    Code Block
    languagec#
    themeRDark
    firstline1
    linenumberstrue
    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");
    		}
    	}
    }


...

  1. Create a new C#  or VB.NET project using Visual Studio project Wizard( **minimum requirement .NET Framework v4.5)

  2. From Solution Explorer, add references to OdaX_xx.x.xx_xx*.dllARESC.exe, and TD_Mgd_xx.x.xx_xx.dll from ARES Commander installation folder.

  3. You can see the available NameSpaces, Class Methods, and Properties in each assembly using Object Browser.

  4. Rename Program.cs to PluginCommands. This changes class Program to class PluginCommands as in the following example:

    Code Block
    languagec#
    themeRDark
    firstline1
    linenumberstrue
    namespace ActiveXCOMSample
    {
    	public class PluginCommands
    	{
    	}
    }

    Defining a command uses Runtime namespace to access the CommandMethod attribute and adds a method with this attribute. See AnyFunctionName() in the following example.
    The following example defines the MySampleCommand command.

    Code Block
    languagec#
    themeRDark
    firstline1
    linenumberstrue
    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 plugins.

  5. Building the sample project generates a dll file named <YourProjectName.dll>

...

Code Block
languagec#
themeRDark
firstline1
linenumberstrue
using Teigha.Runtime;
using PCAD_AC_X;
using System.Runtime.InteropServices;

namespace ActiveXCOMSample
{
	public class PluginCommands
	{
		[CommandMethods("MySampleCommand")]
		public void AnyFunctionName()
		{
			IAcadApplication app = (IAcadApplication)Marshal.GetActiveObject("PCAD_AC_X.AcadApplication");
		}
	}
}

Migrating AutoCAD® ActiveX PlugIn Application to ARES Commander

...