Вы находитесь на странице: 1из 2

Visual Basic or C# 2012 (.NET 4.

0) Page 1 of 2

CSi API ETABS v17

Visual Basic or C# 2012 (.NET 4.0)


1. Create a new project of type Windows Form Application

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();
}

private void button1_Click(object sender, EventArgs e)


{
//set the following flag to true to attach to an existing instance of the program
//otherwise a new instance of the program will be started
bool AttachToInstance;
AttachToInstance = false;

//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";

//full path to the model


//set it to an already existing folder
string ModelDirectory = "C:\\CSi_ETABS_API_Example";
try
{
System.IO.Directory.CreateDirectory(ModelDirectory);
}
catch (Exception ex)
{
MessageBox.Show("Could not create directory: " + ModelDirectory);
}

string ModelName = "ETABS_API_Example.edb";


string ModelPath = ModelDirectory + System.IO.Path.DirectorySeparatorChar + ModelName;

//dimension the ETABS Object as cOAPI type


ETABSv17.cOAPI myETABSObject = null;

//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;

ms-its:C:\Users\Mamamayan\Documents\IYGO\PERSONAL\ETABS API\CSi API E... 21/11/2018


Visual Basic or C# 2012 (.NET 4.0) Page 2 of 2

ETABS®, SAP2000® and CSiBridge® are registered trademarks of Computers and Structures, Inc.
Copyright © Computers and Structures, Inc. 2017. All rights reserved.

Send comments on this topic to support@csiamerica.com

ms-its:C:\Users\Mamamayan\Documents\IYGO\PERSONAL\ETABS API\CSi API E... 21/11/2018

Вам также может понравиться