Python linking grasshopper with Etabs api


I am trying to use the etabs api from grasshopper so I can bring in building structures, amend them in grasshopper and then export back to etabs. When using python 3.5, I use the below code but when I run this in grasshopper it says that there is no module named comtypes. How can I fix this.


import os
import comtypes.client

if not os.path.exists(modelDir):
except OSError:
if AttachToInstance:
except (OSError,comtypes.COMError):
print(“No running instance of the program found or failed to attach.”)

In Grasshopper you are using IronPython which is the C# port of Python. You cannot use it like normal python. Many common modules are not part of it.
You can use the CPython plugin instead (but then you cannot use Rhino functionality), or better you access the com apis with methods provided in DotNet. It may be much easier to write it in c# then, since it can be weird in IronPython. Check stack overflow for it. There are tons of examples.

Which API is this? You’ll need to provide more information to aid in troubleshooting. This also includes how you have installed it and set up your Rhino/GHPython/Python paths etc. etc.

As far as I can tell: this is NOT a standard Python module, you may therefore simply need to install it (i.e. ensure that all the etabs dependencies are installed correctly). Note that it depends on ctypes, which is in fact usable from IronPython, and IS part of the (Iron)Python Standard Library. That said, you may be looking at quite some dependency hell here, but I wouldn’t give up.

The Standard Library for CPython and IronPython are actually more or less identical. I assume you are referring to things like numpy, which is also not part of CPython. Maybe be more specific about things like this, prevent them fake python news from spreading.

I’d suggest trying the same if installing comtypes fails, since it is already working in your external CPython interpreter. There are these two options currently (that I know of):

I assumed that comtypes is part of an standard python install but it wasn’t ported to Ironpython. But I’m not having time nor motivation to prove that. Besides that I wouldn’t do com accessing in script components. I have successfully worked with ctypes in gh, p/invoking my own c library, but I never called a library exposed in com with it. I only did that with catia in a custom plugin done in c# . Com accessing isn’t easy at all and shouldn’t be done without a good debugger in my opinion.

I installed comtypes from pypi using pip install. I might try using c# and see if I can get it to work that way. Thanks for your suggestions and links.

hi, I have the same, issue,
and still can not solve,
if you get the solution, would you share it, please?
actually, now it is passing from this point, and now can not get the “ETABSObject”