Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

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

Status
Not open for further replies.

sunyaer

Structural
Jun 21, 2004
28
Windows 7, Pycharm 2020, Python 3.7, comtypes 1.1.10, attach to Etabs 18.1.1 instance:

Python:
 import sys
import comtypes.client

# 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 = True

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)

# create SapModel object
        SapModel = myETABSObect.SapModel

# initialize model
SapModel.InitializeNewModel()

Error:

File "C:/Users/.../Desktop/Etabs Python/getPierForces.py", line 16, in <module>
myETABSObject = comtypes.client.GetActiveObject("CSI.ETABS.API.ETABSObject")
File "C:\python37\lib\site-packages\comtypes\client\__init__.py", line 183, in GetActiveObject
return _manage(obj, clsid, interface=interface)
File "C:\python37\lib\site-packages\comtypes\client\__init__.py", line 188, in _manage
obj = GetBestInterface(obj)
File "C:\python37\lib\site-packages\comtypes\client\__init__.py", line 112, in GetBestInterface
interface = getattr(mod, itf_name)
AttributeError: module 'comtypes.gen.CSiAPIv1' has no attribute 'cOAPI'

I've searched the forum and found similar threads, and run unRegisterEtabs.exe, and RegisterEtabs.exe, but with no luck to fix the issue. There is a thread which modifies the_init_.py to make it work, but doesn't explain where to modify, so this looks a bit overwhelming to me. Could anyone shed some light on how to fix the error? Thanks in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor