Python 3 Loading DLL File

Hi everyone,

I am trying to load dll file using python3 in Grasshopper, and not sure why it is not regconized. File name and directory are both correct.
Can anyone help me to look at this issue? Please see below snippet for detail.

Thanks in advance
Quang

There are a few packages out there that make use of the ETABS API, and can be used for reference:

I have extracted the following code from pytabs that seems to work:

import os
import sys
import clr
import warnings

etabs_api_path = r'C:\Program Files\Computers and Structures\ETABS 19\ETABSv1.dll'

# pythonnet clr-loader import of Marshal - ETABS API requirement
clr.AddReference("System.Runtime.InteropServices")

# pythonnet clr-loader try import of ETABS API DLL (ETABSv1.dll)
warnings.filterwarnings('default')
clr.AddReference(etabs_api_path)

import ETABSv1 as etabs
1 Like

I didn’t know that clr.AddReference refers to sys.path, but line 12 stores the directory’s parent directory in dll_directory. Possibly not the directory containing the dll (else why enter that whole path in the first place?).

Thanks, I correct the path of DLL file, but not sure why same error is persisted.

Thanks Andrew.

I revised the code as below and now it works

But now I encounter another issue

Not sure what happens, code can run with Spyder with no issue.