×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Error when getting Python to attach to ETABS

Error when getting Python to attach to ETABS

Error when getting Python to attach to ETABS

(OP)
Hi, I'm using the following code:

import sys
import comtypes.client

try:
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)
SapModel = myETABSObject.SapModel

I'm getting an attribute error:

AttributeError: module 'comtypes.gen.CSiAPIv1' has no attribute 'cOAPI'

Does anyone know how to fix this?

I'm using Pycharm, ETABS v18.
Replies continue below

Recommended for you

RE: Error when getting Python to attach to ETABS

(OP)
Hi. Thanks for the reply! I actually saw this thread before posting but I don't really understand what the __init__ file is doing. Are you able to provide any context? Do I need to have that at the beginning of my code? It seems Bjorn managed to fix his issue but didn't explain why.

RE: Error when getting Python to attach to ETABS

I can't say I completely understand the usage of an __init__.py file for python packages.

What comtypes version are you using. When I first started using the etabs API with python early in 2019 I was using comtypes version 1.1.2, that was giving me some trouble and I had to change a little bit of the __init__.py file to get it working, I remember it being something like a try block with no exception catch. However, many of my colleagues started using my scritps and they where using comtypes 1.1.7 (still current release). Now, I think there are still some bugs with this version of comtypes, I still get errors when trying to get modal output. Will try and did into it a bit further. But what version of comtypes are you using.

RE: Error when getting Python to attach to ETABS

(OP)
I am working in comtypes 1.1.7. I actually switched to Anaconda instead of Pycharm and it seemed to fix the issue, I have no clue why.

RE: Error when getting Python to attach to ETABS

Same here, one of my colleagues also had the same issue and I can't work it out but think it has something to do with the file that get's generated in the comtypes.gen folder. Best fix I found is uninstall and re-install.

How are the scripts going, I see by some of your other posts that you are looking to write a few custom functions to automate your workflow?

RE: Error when getting Python to attach to ETABS

(OP)

Quote (rscassar)

How are the scripts going, I see by some of your other posts that you are looking to write a few custom functions to automate your workflow?

First code I'm going to write it to take raw coordinate data from Revit (using a dynamo script) and then develop a python code that will build a model with the geometric data in ETABS. I think it will be a good project to develop an understanding of the API. Then I'm not sure which direction I will go, I feel like understanding ETABS API will open a lot of doors for automation!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close