Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Etabs Api : NewGridOnly Method

Status
Not open for further replies.

Ganesh_maka

Structural
Feb 28, 2024
4
Can you please help me with this code
I am getting the same Grid spacing But I want different spacing

import comtypes.client
import os
import sys

# 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
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
SpecifyPath = False

# If the above flag is set to True, specify the path to ETABS below
ProgramPath = "C:\\Program Files (x86)\\Computers and Structures\\ETABS 18\\ETABS.exe"

# Full path to the model
# Set it to the desired path of your model
APIPath = 'C:\\CSi_ETABS_API_Example'
if not os.path.exists(APIPath):
try:
os.makedirs(APIPath)
except OSError:
pass
ModelPath = APIPath + os.sep + 'API_1-001.edb'

try:
if AttachToInstance:
# Attach to a running instance of ETABS
try:
# Get the active ETABS object
myETABSObject = comtypes.client.GetActiveObject("CSI.ETABS.API.ETABSObject")
except (OSError, comtypes.COMError):
print("No running instance of the program found or failed to attach.")
sys.exit(-1)
else:
# Create API helper object
helper = comtypes.client.CreateObject('ETABSv1.Helper')
helper = helper.QueryInterface(comtypes.gen.ETABSv1.cHelper)
if SpecifyPath:
try:
# Create an instance of the ETABS object from the specified path
myETABSObject = helper.CreateObject(ProgramPath)
except (OSError, comtypes.COMError):
print("Cannot start a new instance of the program from " + ProgramPath)
sys.exit(-1)
else:
try:
# Create an instance of the ETABS object from the latest installed ETABS
myETABSObject = helper.CreateObjectProgID("CSI.ETABS.API.ETABSObject")
except (OSError, comtypes.COMError):
print("Cannot start a new instance of the program.")
sys.exit(-1)

# Start ETABS application
myETABSObject.ApplicationStart()

SapModel = myETABSObject.SapModel

# Initialize model
SapModel.InitializeNewModel()

# Define grid system parameters
NumberStorys = 3
TypicalStoryHeight = 12
BottomStoryHeight = 12
Lines_X = 4
Lines_Y = 4

# Define different spacings for each line along X and Y axes
SpacingX = [5, 8, 13] # Adjust these values for desired spacing along X axis
SpacingY = [5, 8, 13] # Adjust these values for desired spacing along Y axis

# Create grid lines with different spacings along X axis
for i in range(Lines_X ):
for k in range(Lines_Y):
ret = SapModel.File.NewGridOnly(NumberStorys, TypicalStoryHeight, BottomStoryHeight,
Lines_X, Lines_Y, SpacingX,SpacingY[k])


# myETABSObject.ApplicationExit(False)

except Exception as e:
print(f"Error: {e}")
 
Replies continue below

Recommended for you

I have had more luck with gridlines using the database tables
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor