Message 1 of 2
Calling a function of DLL from Python
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
My question relates to the custom component creation using Python Scripting. I am sure you are familiar with this approach but as a recap;
- Type in the python script to create the needed geometry and save it in CustomScript folder
- Compile it from autocad plant 3d using PLANTREGISTERCUSTOMSCRIPT
- test is using TESTACPSCRIPTS method
Now, what I want is a way to call some boolean function TEST from a DLL file placed inside CustomScript folder as well and check whether it returned a true or false. so far what I have tried is this;
import clr
clr.AddReference("SampleDLL")
from SampleDLLNameSpace import SampleDLL
def SAMPLECODE(ID="SAMPLECODE", **kw):
if(SampleDLL.TEST):
print("OK")
else:
print("NOT OK")and
import ctypes
def SAMPLECODE(ID="SAMPLECODE", **kw):
lib = ctypes.CDLL("SampleDLL")
if(lib.TEST):
print("OK")
else:
print("NOT OK")
When i try and compile the script using PLANTREGISTERCUSTOMSCRIPT command, it throws an error in both cases;
ModuleNotFoundError: No module named '_clr'
ModuleNotFoundError: No module named '_ctypes'
So any thought on how can I call the function from an external DLL file. Your help is always appreciated