Sunteți pe pagina 1din 3

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
ASMgd
ASGeometryMgd
ASCADLinkMgd
ASProfilesMgd
ASModelerMgd

\DSCCommon
\implementation\Bin
\Kernel\implementation\Bin
\DSCCommon
\implementation\Bin
\Kernel\implementation\Bin
\DSCCommon
\implementation\Bin
\DSCCommon
\implementation\Bin

Required to compile the addin.


Main Advance Steel objects access
Advance Steel geometry needed to
interact with Advance Steel objects
CAD related objects access (database,
object id, )
Advance Steel profiles database access
Advance Steel modeler access

The names of the modules listed above are usually decorated with some more numbers and /
or letters related to the Advance Steel version to which they belong, 32 / 64 bit architecture,
8. Add a new registry key
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AdvanceSteel\<Advance_Steel_ Version_Number>
\NETAddins\<Addin_Name>]
"InstallLocation"="<dll_path>\<file_name>"

See also sample reg file from sample project


This key is used by Advance Steel to automatically load your addin on startup

9. Start Advance Steel and run your command.

S-ar putea să vă placă și