With the release of ETABS v22.0.0 , it is now possible to create plugins for CSI products using .NET 8 . To learn more about the .NET 8 platform , please see What's new in .NET 8 . This example will guide a developer through creating a simple .NET 8 plugin for ETABS v22.0.0 using the C# programming language. For an example plugin using .NET Framework, please see NET Framework Plugin Example .
This walkthrough uses Microsoft Visual Studio 2022 and the .NET 8 SDK. ETABS v22.0.0 must be installed on the development computer.
![]()
2. For convenience, set your project name to the desired name of your plugin.
![]()
3. Select .NET 8.0 as the desired Framework
![]()
4. Once your project is created, add a reference to the CSI API library. This will be located in the installed ETABS directory, typically C:\Program Files\Computers and Structures\ETABS 22\ . If you are making a plugin only for ETABS, select the ETABSv1.DLL . If you'd like your plugin to be compatible with other CSi products, such as SAFE or SAP2000, use the cross-product API library, CSiAPIv1.DLL .
![]()
5. Rename the Class1.cs file to cPlugin.cs and paste in the following code
using CSiAPIv1;
namespace CSiNET8PluginExample1
{
public class cPlugin : cPluginContract
{
private static string _modality = "Non-Modal";
internal static string _versionString = "2.0";
public int Info(ref string Text)
{
try
{
Text = "This plugin is supplied by Computers and Structures, Inc., " +
"as a simple example for developers of new plugins for CSI products. " +
"It starts a new blank model, then converts a line of text into " +
"frame objects and adds them to the model. If you enter the " +
"text \"crash\", an error will be generated for testing purposes. " +
"Version " + _versionString;
}
catch (Exception)
{
}
return 0;
}
public void Main(ref cSapModel sapModel, ref cPluginCallback pluginCallback)
{
var aForm = new Form1();
try
{
aForm.SetSapModel(ref sapModel, ref pluginCallback);
if (string.Compare(_modality, "Non-Modal", true) == 0)
{
// Non-modal form, allows graphics refresh operations in CSI program,
// but Main will return to CSI program before the form is closed.
aForm.Show();
}
else
{
// Modal form, will not return to CSI program until form is closed,
// but may cause errors when refreshing the view.
aForm.ShowDialog();
}
// It is very important to call pluginCallback.Finish(iError) when the form closes, !!!
// otherwise, the CSI program will wait and be hung !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// This must be done inside the closing event for the form itself, not here !!!!!!!!!!!
// If you simply have algorithmic code here without any forms,
// then call pluginCallback.Finish(iError) here before returning to the CSI program
// If your code will run for more than a few seconds, you should exercise
// the Windows messaging loop to keep the program responsive. You may
// also want to provide an opportunity for the user to cancel operations.
}
catch (Exception ex)
{
MessageBox.Show("The following error terminated the plugin:" + Environment.NewLine + ex.Message);
// call Finish to inform the CSI program that the plugin has terminated
try
{
pluginCallback.Finish(1);
}
catch (Exception)
{
}
}
}
}
}
|