02-25-2022 03:29 AM
Hello,
I was wondering if it is possible to call DIAdem and access the Application object from an externally launched python script.
Here's what I have tried so far:
import sys
import os
sys.path.append(R"C:\Program Files\National Instruments\DIAdem 2021")
os.add_dll_directory(R"C:\Program Files\National Instruments\DIAdem 2021")
import DIAdem
Simply appending the installation directory to sys.path is enougth to find the DIAdem module but throws a
FileNotFoundError: Could not find module 'GfSGPI.dll'
Adding the dll directory gets one line further, but then causes an acces violation:
Traceback (most recent call last):
File "c:\_WIP_\DIAdem test\call_dd.py", line 7, in <module>
import DIAdem
File "C:\Program Files\National Instruments\DIAdem 2021\DIAdem.py", line 203, in <module>
vp=GPI.TOCMDGet()
OSError: exception: access violation reading 0x0000000000000010
Now I was figuring, before I go poking around with dlls and ctypes I should ask if this use case is even possible / supported.
Or are Python scripts only supported when launched from within DIAdem?
03-10-2022 09:40 PM
Hi maflAut,
Just want to give a try on this.
Have you tried to first open DIAdem using Python?
I used the subprocess to open DIAdem.
import subprocess
subprocess.Popen([r"C:\Program Files\National Instruments\DIAdem 2021\DIadem.exe"])
This works.
Then, the next logic is to check if the DIAdem is already running.
If its already running, perhaps you can add the some Python code to access the Application object.
This is the idea I had but it worth trying out and see if it works.
03-11-2022 11:03 AM
Hello guserwin91,
thanks for the tip.
Unfortunately it doesn't seem to make a difference if the the application is running or not.
I also tried running the script with the Python distribution that is shipping with Diadem as well as with the official Python disttribution.
This doesn't make a difference either.
03-11-2022 08:53 PM
Hi maflAut,
Can you show where can I find this script with the Python distribution that is shipping with Diadem as well so I can try to give a test?
Regards
03-14-2022 04:04 PM
You can find the included distribution in C:\Program Files\National Instruments\Shared\Skyline\Python.
07-15-2022 03:43 AM
did anyone find a solution?
07-15-2022 04:49 AM
Unfortunately no, but I got confirmation from official support, that this use case is not supported.
09-13-2022 02:35 AM
Hello
I had same problem with "Application" object when i tryed to implement this VBS Script in Python.
After copule of weeks of try and error and with help of some luck, I manage to get my Python script work.
Long story short...
I've got working "Application" object in external Python script by using:
self.DIAdemApp=win32com.client.dynamic.Dispatch("DIAdem.TOCmd")
insted of:
Call oDIAdem.VariantVarget("Application",DIAdemApp)
in VBS script example.
Rest of Python script was rewriten as one to one from example, using comtypes library, using 'comtypes.client.CreateObject' to create 'TOCommand' object.
Hope this will help
P.S
I was using Diadem 2021 and Python 3.8.6