Use the Advance Steel API and C# to create a Hello World program using the directions provided.
The Hello World walkthrough covers the following topics:
All operations and code in this section were created using Visual Studio 2012.
The first step in writing a C# program with Visual Studio is to choose a project type and create a new Class Library.
Figure 1: Add New Project
A number of components make up the Advance Steel API. They are installed with Advance Steel and can be found in subdirectories of the Advance Steel 20xx program folder, where 20xx is the version number of Advance Steel, such as 2015 or 2016. You need to add references to the following components in order to compile the project. Note that some components have different names depending on which version of Advance Steel you have installed.
| Component | Location | Description |
|
ASNetRuntime.dll |
\Advance Steel 20xx\Common\Bin |
Required to compile the Addin |
|
ASMgd.dll |
\Advance Steel 20xx\Kernel\Bin |
Main Advance Steel objects access |
|
ASCADLinkMgd.dll |
\Advance Steel 20xx\Kernel\Bin |
CAD - related objects access (database, object id, …) |
|
ASGeometryMgd64.dll or ASGeometryMgd32.dll |
\Advance Steel 20xx\Common\Bin |
Advance Steel geometry - needed to interact with Advance Steel objects |
|
ASProfilesMgd64.dll or ASProfilesMgd32.dll |
\Advance Steel 20xx\Common\Bin |
Advance Steel profiles database access |
|
ASModelerMgd64.dll or ASModelerMgd32.dll |
\Advance Steel 20xx\Common\Bin |
Advance Steel modeler access |
To add references to the required components, follow these steps:
There are three main steps to adding code to an Advance Steel Addin:
A default class called Class1 should have been created with the new project.
|
Code Region: Implement IExtensionApplication |
using Autodesk.AdvanceSteel.Runtime;
namespace HelloWorld
{
public sealed class Plugin : IExtensionApplication
{
void IExtensionApplication.Initialize()
{
}
void IExtensionApplication.Terminate()
{
}
}
}
|

Figure 2: Use Intellisense to implement the interface
|
Code Region: Create a command class |
using Autodesk.AdvanceSteel.CADAccess;
using Autodesk.AdvanceSteel.DocumentManagement;
using Autodesk.AdvanceSteel.Runtime;
using System.Windows.Forms;
namespace HelloWorld
{
public class TestClass
{
[CommandMethodAttribute("TEST_GROUP", "HelloWorld", "HelloWorld", CommandFlags.Modal)]
public void SayHelloWorld()
{
MessageBox.Show("Hello World!");
}
}
}
|
An Advance Steel addin must have a method with the CommandMethodAttribute as shown in the sample code above. The parameters for the CommandMethodAttribute are:
Note that the options for CommandFlags are the same as for the AutoCAD Managed .NET API and the full list of options can be found here.
An Advance Steel addin must include certain Informational Attribute directives. These belong in the AssemblyInfo.cs files.
|
Code Region: Add an ExtensionApplicationAttribute |
[assembly: ExtensionApplicationAttribute(typeof(HelloWorld.Plugin))] |
|
Code Region: Add a CommandClassAttribute |
[assembly: CommandClassAttribute(typeof(HelloWorld.TestClass))] |
After following these steps, the AssemblyInfo.cs file will look something like this:
|
Code Region: Sample AssemblyInfo.cs |
using Autodesk.AdvanceSteel.Runtime;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("HelloWorld")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HelloWorld")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ExtensionApplicationAttribute(typeof(HelloWorld.Plugin))]
[assembly: CommandClassAttribute(typeof(HelloWorld.TestClass))]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("85900596-22ee-4873-bbd6-7f970d32b5af")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
|
After compiling the code, you need to add a new registry key that will be used by Advance Steel to automatically load your addin on startup. The new key should be:
[HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AdvanceSteel\<Advance_Steel_Version_Number>\NETAddins\<Addin_Name>]
"InstallLocation"="<addin_dll_path>\<file_name>"
<Advance_Steel_Version_Number> will be the version of Advance Steel for the addin, such as "2016". <Addin_Name> is the name of the Advance Steel addin, and the InstallLocation points to the full pathname of the addin .dll file.
The image below shows the new registry key for the HelloWorld addin for Advance Steel 2016.
Figure 2: Add a registry key
This only needs to be done once per addin .dll. Any new commands added to the assembly designated by the " CommandMethodAttribute" attribute will be automatically recognized as a separate command that can be run when Advance Steel is loaded.
To run the addin command, start Advance Steel. Then simply type in the name of the command, in this case, HelloWorld, and hit enter.
If you need to debug your addin, you can follow these steps: