Versions Compared

Key

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

ARES commander provide Commander provides .NET API to that lets you author third party Plugin Software for ARES Commander.

Supported API Sets 

ARES Supports 3 Commander supports three API sets which that you can be used use independently.

  1. .NET Classic API
  2. ARES COM API
  3. CFx .NET (SWIG generated .NET API version of ARES C++ SDK)
API Assembly NamesNature of PluginLoading Mechanism
NET Classic API

TD_Mgd_x.xx_xx.dll

FxCoreMgd_x.xx_xx.dll

In-processUse the NETLOAD command

ARES COM API

ARESC.exe

OdaX_x.xx_xx.dll

TD_Mgd_x.xx_xx.dll(For In-process plugin only)

In-process

Out-process

 
  • In-process-Use the NETLOAD command
  • Out-rocess-  Runs as a separated EXE
CFx .NET

ArgonMGD.dll

TD_SwigCoreMgd.dll

TD_SwigDbMgd.dll

TG_SwigDbMgd.dll

TD_Mgd_x.xx_xx.dll

In-processUse the NETLOAD command


Creating a .NET Classic Plugin:

  1. Create a new

...

  1. C# or VB.NET

...

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

    Image Modified

...

  1. From Solution Explore

...

  1. , add references of TD_Mgd_x.xx_xx*.dll

...

  1. and FxCoreMgd_x.xx_xx.dll

...

  1. from the ARES Commander installation folder.

    Image Modified

...


  1. You can

...

  1. see all available NameSpaces, Classes, Methods, and Properties in each assembly

...

  1. in the Object Browser.

    Image Added

...

  1.            

...

  1. Rename Class1.cs

...

  1. to PluginCommands.cs

...

  1. . This changes the class Class1 to class PluginCommands

...

  1. , as in the following example.

    Image Modified
  2. Defining a command

...

  1. uses Teigha.Runtime namespace to access CommandMethod method

...

  1. attribute and

...

  1. adds a method

...

  1. , such as AnyFunctionName that has this attribute.

...

  1. The following example defines the MySampleCommand command which

...

  1. you can run later in ARES Commander, from the command prompt.
    You can define all types of in-process

...

  1. plugin using a similar procedure.
    Image Added
  2. Build the sample project

...

  1. to generate PluginCommans.dll or <YourProjectName.dll>.

...

  1. Start ARES Commander and type NETLOAD

...

  1. at the command

...

  1. prompt. Next, browse and load the plugin dll

...

  1. (PluginCommands.dll

...

  1. ).
    The coommand window displays a confirmation message.
  2. Run

...

  1. MySampleCommand, which executes the AnyFunctionName method

...

Accessing Application Object

Accessing Documents and ActiveDocument

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
  • Add a new document
  • Open existing drawings.

Image Added 

Prompting for User Input 

The Editor class controls the user input and prints the output into command window. All related classes for prompting on the command window are available in Teigha.EditorInput namespace.

Code Block
languagec#
themeFadeToGrey
linenumberstrue
            Document activeDocument = docManager.MdiActiveDocument;
            Editor ed = activeDocument.Editor;

            PromptIntegerOptions op = new PromptIntegerOptions("Input a positive integer");
            op.AllowNegative = false;
            PromptIntegerResult res =(PromptIntegerResult) ed.DoPrompt(op);
            if( res.Status == PromptStatus.OK)
            {
                int retVal = res.Value;
            }


Creating .NET Extension Application

.NETExtension Application lets you run your code while loading the plugin. For example, you can create the Plugin as an Extension Application to display tabs on the Ribbon or palettes while the plugin is loading in the software.

To create the Plugin as an Extension Application, add a class that implements IExtensionApplication interface. Each plugin can have only one class of this type.

When you load the plugin using the NETLOAD command, the software automatically calls public void Initialize(). When the System unloads the plugin, it calls Terminate.

Image Added


Defining .NET LispFunction

Third party can define .NET methods that you can use later in LISP. The following example defines the lisptest function using the LispFunction Method attribute.

To call the lisptest function, use the following LISP script:

(setq x (lisptest "Text created by .NET lisp function" 1.0 '(10 10 0)))


Code Block
languagec#
themeFadeToGrey
linenumberstrue
        //Method attribute to define lisp callable function 'LispTest' 
        //i.e (setq x (lisptest "Text created by .NET lisp function" 1.0 '(10 10 0)))
        [LispFunction("lisptest")]
        public ResultBuffer DoIt(ResultBuffer args)
        {
            // Get the database of the active document.
            Database db = HostApplicationServices.WorkingDatabase;
            TypedValue[] argsVal = new TypedValue[3];
            if (args != null)
            {
                argsVal = args.AsArray();
            }
            else
            {
                argsVal[0] = new TypedValue((int)LispDataType.Text, "Default Text");
                argsVal[1] = new TypedValue((int)LispDataType.Double, .2);
                argsVal[1] = new TypedValue((int)LispDataType.Point3d, new Point3d(0, 0, 0));
            }
            // Set up transaction manager.
            Teigha.DatabaseServices.TransactionManager tm = db.TransactionManager;
            using (Transaction tr = tm.StartTransaction())
            {
                try
                {
                    Point3d pPosition = new Point3d(0, 0, 0);

                    // Create a new MText object and set properties.
                    DBText pText = new DBText();
                    pText.TextString = (String)argsVal[0].Value;
                    pText.Height = Convert.ToDouble(argsVal[1].Value);
                    pText.Position = (Point3d)argsVal[2].Value;

                    // Get model space to add the MText object.
                    BlockTable pBlockTable = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForWrite);
                    BlockTableRecord pModelSpace = (BlockTableRecord)tr.GetObject(pBlockTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite);

                    // Add the object to the model space.
                    ObjectId id = pModelSpace.AppendEntity(pText);
                    tr.AddNewlyCreatedDBObject(pText, true);

                    // Commit changes to database.
                    tr.Commit();
                    //return created text entity to lisp
                    return new ResultBuffer(new TypedValue((int)LispDataType.ObjectId, id));
                }
                finally
                {
                    // delete tr , managed by c# with garbage collection
                }

            }
        }