0) Page 1 of 2
2. Add a reference to “ETABSv17.dll” to the .NET project. This early binds to the API using the .NET interface.
3. Add a button to the form, double-click the button, then paste in the following, ready-to-run code.
C# VB
Copy
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//set the following flag to true to manually specify the path to ETABS.exe
//this allows for a connection to a version of ETABS other than the latest installation
//otherwise the latest installed version of ETABS will be launched
bool SpecifyPath;
SpecifyPath = false;
//if the above flag is set to true, specify the path to ETABS below
string ProgramPath;
ProgramPath = "C:\\Program Files (x86)\\Computers and Structures\\ETABS 17\\ETABS.exe";
//Use ret to check if functions return successfully (ret = 0) or fail (ret = nonzero)
int ret = 0;
if (AttachToInstance)
{
//attach to a running instance of ETABS
try
{
//get the active ETABS object
myETABSObject = (ETABSv17.cOAPI)System.Runtime.InteropServices.Marshal.GetActiveObject("CSI.ETABS.API.ETABSObject"
}
catch (Exception ex)
{
MessageBox.Show("No running instance of the program found or failed to attach.");
return;
}
}
else
{
//create API helper object
ETABSv17.cHelper myHelper;
ETABS®, SAP2000® and CSiBridge® are registered trademarks of Computers and Structures, Inc.
Copyright © Computers and Structures, Inc. 2017. All rights reserved.