Issue connecting to "StaadPro.OpenStaad" using Comtypes

I am following along in the tutorials for using Staad.Pro with python but when I run:

os = comtypes.client.GetActiveObject(“StaadPro.OpenSTAAD”)

I get the error below.

When I check in regedit.exe none of the HK registries contain StaadPro.OpenSTAAD nor do the StaadPro folders contain CLSID or ProgID.

Is there something I am missing? I am using Staad at work and it is installed from a company software installation platform.

Any assistance will be greatly appreciated


OSError Traceback (most recent call last)
Cell In[5], line 4
2 from comtypes import client
3 import ctypes
----> 4 os = comtypes.client.GetActiveObject(“StaadPro.OpenSTAAD”)

File c:\Users\piet15245\OpenStaad\Test.venv\Lib\site-packages\comtypes\client_init_.py:164, in GetActiveObject(progid, interface, dynamic)
153 def GetActiveObject(progid, interface=None, dynamic=False):
154 # type: (_UnionT[str, CoClass, GUID], Optional[Any], bool) → Any
155 “”“Return a pointer to a running COM object that has been
156 registered with COM.
157
(…) 162 ‘dynamic=True’ will return a dynamic dispatch object.
163 “””
→ 164 clsid = GUID.from_progid(progid)
165 if dynamic:
166 if interface is not None:

File c:\Users\xxxxx\OpenStaad\Test.venv\Lib\site-packages\comtypes\GUID.py:86, in GUID.from_progid(cls, progid)
84 return cls(progid)
85 inst = cls()
—> 86 _CLSIDFromProgID(text_type(progid), byref(inst))
87 return inst
88 else:

File _ctypes/callproc.c:1009, in GetResult()

OSError: [WinError -2147221005] Invalid class string

I’m assuming you’re following the Integrate with STAAD.pro tutorial. I’ve got a question… Do you have an instance of STAAD open? The comtypes.client.GetActiveObject(“StaadPro.OpenSTAAD”) tries to access a running instance, regardless if there’s nothing modelled in the software.