Versions Compared

Key

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

These plug-ins are of two typesThere are two types of ActiveX/COM plugins:

  • Out-Process:Runs The plugin runs as a separate .exe file.
  • In-Process:Using NETLOAD Load and run the pluglin using the NETLOAD command.

Out-Process Active/COM Plugins

  1. Create a new C#  or VB.NET

...

  1. project using the Visual Studio project Wizard( **minimum requirement .NET Framework v4.

...

  1. 8).
    One can either create Windows Form Application, Console Application, or Class Library.

    Image Modified

...

  1. From Solution Explorer, add references to OdaX_xx.x

...

  1. _xx*.

...

  1. dll and ARESC.exe

...

  1. from ARES Commander installation folder.

    Image Modified

...

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

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

    Image Modified
  3. Rename Program.cs to PluginCommands

...

  1. . This changes class Program to class PluginCommands

...

  1. as in the following example.

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


  2. There are two ways to work with an out

...

  1. -process plugin:
    • Create a new Instance

...

    • Attach the debugger while the application is running

  1. To create an Instance of AcadApplication

...

  1. , 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();
    		}
    	}
    }

...

  1. If ARES Commander is already running, use a version dependent ProgIDs or

...

  1. 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");
    		}
    	}
    }


Accessing  Documents and Active Documents

From the application object

...

you can access collection of documents or active documents and

...

preferences.

...

The following code iterates through the document collection.

Code Block
languagec#
themeRDark
firstline1
linenumberstrue
foreach(AcadDocument Doc in app.Application.Documents)
{
	Console.Writeline("\n" + Doc.Name);
}

...

The following code gets the active document.

Code Block
languagec#
themeRDark
firstline1
linenumberstrue
AcadDocument NewDrawing;
NewDrawing = app.ActiveDocument;

...

The following code accesses the display preferences.

Code Block
languagec#
themeRDark
firstline1
linenumberstrue
IAcadPreferencesDisplay AcadPref;
AcadPref = app.Preferences.Display;
int Size = AcadPref.CursorSize;

Prompting For User Input

Utility functions

...

let you

...

request input from the user

...

and perform geometric calculations.

...

 You can access Utility functions through the ActiveDocument object.

...

Various Utility functions prompt user for input. For example, GetInteger() allows integer input. Similar methods allow prompting for Angle, Distance, AngleFromAxis, and Keyword

...

.

...

For reference, see the following code

...

.

Code Block
languagec#
themeRDark
firstline1
linenumberstrue
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 Active/COM Plugins

  1. Create a new C#  or VB.NET

...

  1. project using Visual Studio project Wizard( **minimum requirement .NET Framework v4.5)

    Image Modified

...

  1. From Solution Explorer, add references to OdaX_xx.x

...

  1. _xx*.dllARESC.exe, and TD_Mgd_xx.x

...

  1. _xx.dll

...

  1. from ARES Commander installation folder.

    Image Modified

...

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

    Image Modified
  2. Rename Program.cs to PluginCommands

...

  1. . This changes class Program to class PluginCommands

...

  1. as in the following example:

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

    Defining a command

...

  1. uses Runtime namespace to access the CommandMethod

...

  1. attribute

...

  1. and

...

  1. adds a method

...

  1. with this attribute.

...

  1. 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()
    		{
    		}
    	}
    }

...

  1. Using a similar procedure, you can create all types of in-process

...

  1. plugins.

...

  1. Building the sample project

...

  1. generates a dll file named <YourProjectName.dll>

...

Running the NETLOAD Command

  1. Start ARES Commander.
  2. Type NETLOAD at the command prompt and press Enter. Navigate to PluginCommands.dll and load it.
    The command window displays a confirmation message.
  3. Run MySampleCommand which executes the AnyFunctionName method.
  4. Because ARES Commander is already running, use GetActiveObject method instead of creating an instance of AcadApplication.
  5. For Marshal, use System.Runtime.InteropServices

Use the same steps to access various ActiveX/COM objects and collections.

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");
		}
	}
}
  • Rest procedure for accessing various ActiveX/COM objects and collections is same.

...

Migrating AutoCAD® ActiveX PlugIn Application to ARES Commander

The You can easily migrate ActiveX/COM applications running on AutoCAD platform can be easily migrated AutoCAD® platform to ARES Commander by making minimal changes..

The following changes are necessary:

  • Replace AutoCAD® ActiveX/COM assemblies by ARES ActiveXARES ActiveX/COM (OdaX_x.xx_xx and ARESC.exe) assemblies.
  • Replace Autodesk.AutoCAD namespace by Teigha namespace in source code.
  • Replace AutoCAD to AutoCAD to PCAD_AC_X and AXDBLiB to PCAD_DB_X in source code.

...

  • .