You are on page 1of 2

How to create an AS.

NET Addin

Advance Steel (starting with version 2015) supports loading and executing external code in the form of .NET assemblies. We
refer to this as “Plugins” or “Addins”.

The steps required to create, load and get code inside such an assembly executed are detailed below:

(Examples are given below for c# but all languages supported by the .NET framework should work just as well)

1. Create a new .Net Framework dll.

2. Create a new class and implement IExtensionApplication interface

namespace TestNamespace
{
public sealed class Plugin : IExtensionApplication
{
void IExtensionApplication.Initialize()
{
}
void IExtensionApplication.Terminate()
{
}
}
}

3. Add an “Informational Attribute” directive (usually in AssemblyInfo.cs):


[assembly: ExtensionApplicationAttribute(typeof(TestNamespace.Plugin))]

(Notice the type given as parameter: it is the type of the class which implements “IExtensionApplication”)
This is what makes your .Net framework dll an Advance Steel Addin.

4. Create a new “command” class – this is where Advance Steel calls you when the user types the command you
register in AutoCAD

public class TestClass


{
[CommandMethodAttribute("TEST_GROUP", "CreateElements", "CreateElements",
CommandFlags.Modal | CommandFlags.UsePickSet | CommandFlags.Redraw)]
public void Create()
{
DocumentManager.lockCurrentDocument();
TransactionManager.startTransaction();

//your code here


TransactionManager.endTransaction();
DocumentManager.unlockCurrentDocument();
}
}

5. Add a new “Informational Attribute” directive:


assembly: CommandClassAttribute(typeof(TestNamespace.TestClass))]
Notice again the type given as parameter: it is the type of the class in which you implement a “Command”
Only inside classes for which such information exists can register commands

6. Inside your “Command” class you should create a method and decorate it with the “CommandMethodAttribute”
attribute. The attribute takes as parameters a

groupName - the group name where to add the command to. If the group doesn't exist, it is
created before the command is added.
globalName - command name to add. This name represents the global or untranslated name
localizedNameId - command name to add. This name represents the local or translated name
flags - Flags associated with the command.

7. In order to be able to compile, you will need to add references to your project several of the following modules:

ASNetRuntime Required to compile the addin.


ASMgd Main Advance Steel objects access
ASGeometryMgd Advance Steel geometry – needed to interact with
Advance Steel objects
ASCADLinkMgd CAD – related objects access (database, object id,
…)
ASProfilesMgd Advance Steel profiles database access
ASModelerMgd Advance Steel modeler access

The modules can be found in the following folder: C:\Program Files\Autodesk\AutoCAD 2018\ADVS\.

8. Add a new setting key in ASSettings_Advance.xml

[HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AdvanceSteel\<Advance_Steel_ Version_Number>
\NETAddins\<Addin_Name>]
"InstallLocation"="<dll_path>\<file_name>"

This key is used by Advance Steel to automatically load your addin on startup. More details about this can be found here:
http://help.autodesk.com/view/ADSTPR/2018/ENU/?guid=GUID-B1F6F472-52E6-49B7-851F-1D8E1519F850

9. Start Advance Steel and run your command.

You might also like