I am running ZEN(blue) 2.6 on Win10 with Matlab 9.5 / 8.5 and I am having troubles getting this example to run:
https://github.com/sebi06/ZEN_Matlab/blob/master/RunZenExperimentFromMATLAB.m
after registering the DLLs with regScripting_Release.bat as Admin and enabling the service with
enableservice('AutomationServer',true)
When I try:
Zen = actxGetRunningServer('Zeiss.Micro.Scripting.ZenWrapperLM');
I get back an Zen object if ZEN is running ( and an error otherwise). However the Zen Object is empty:
Zen.IsLiveRunning does not change independent of the actual state in ZEN.
The experiment ('bob') that I have defined in ZEN is not visible and consequently I can't access it:
ZEN_Experiment = 'bob.czexp';
exp = Zen.Acquisition.Experiments.GetByName(ZEN_Experiment);
leads to an error "Attempt to reference field of non-structure array" or "dot indexing not allowed" (depending on the version of Matlab).
I have no idea what I do wrong and would appreciate any help!
I should say that the reverse way (ZEN calling Matlab ) works and I have no problem whatsoever to run MATLAB from a czmac.
For example:
from System.Runtime.InteropServices import Marshal
from System.IO import Path, File, Directory, FileInfo
import os
MATLAB = Marshal.GetActiveObject('MATLAB.Application.9.5')
MATLAB.execute("eval('2+2')")
exp=Zen.Acquisition.Experiments.GetByName("bob")
img=Zen.Acquisition.Execute(exp)
MATLAB.PutWorkspaceData("A", "base", img)
works fine.
Robert
COM interface MATLAB ==> ZEN
apparently the COM interface is currently broken in Zen 2.6
and will be fixed with an upcoming hotfix
Robert
Robert
Still broken even after Hotfix?
As mentioned in this thread, the COM Object for external OAD Scripting usage seems to be broken. Though I applied the mentioned Hotfix 5 to my Zen Version (Zen Blue 2.6). Although the Zen Version I'm using is not upgraded from a former Zen Version as e.g. 2.3 but a fresh installed one.
Unfortunately I'm still running into problems calling the COM object from python.
When I'm trying to run this script:
import sys
import os
import win32com.client
Zen = win32com.client.GetActiveObject("Zeiss.Micro.Scripting.ZenWrapperLM")
i get the error message:
Traceback (most recent call last):
File "ZeissTestScript.py", line 5, in <module>
Zen = win32com.client.GetActiveObject("Zeiss.Micro.Scripting.ZenWrapperLM")
File "C:\Program Files\Python36\lib\site-packages\win32com\client\__init__.py", line 78, in GetActiveObject
resultCLSID = pywintypes.IID(Class)
pywintypes.com_error: (-2147221005, 'Ungültige Klassenzeichenfolge', None, None)
also a look at the registry shows that the object isn't registered.
I have no idea what I do wrong and would appreciate any help especially after applying the mentioned hotfix!
Best Regards
Unfortunately I'm still running into problems calling the COM object from python.
When I'm trying to run this script:
import sys
import os
import win32com.client
Zen = win32com.client.GetActiveObject("Zeiss.Micro.Scripting.ZenWrapperLM")
i get the error message:
Traceback (most recent call last):
File "ZeissTestScript.py", line 5, in <module>
Zen = win32com.client.GetActiveObject("Zeiss.Micro.Scripting.ZenWrapperLM")
File "C:\Program Files\Python36\lib\site-packages\win32com\client\__init__.py", line 78, in GetActiveObject
resultCLSID = pywintypes.IID(Class)
pywintypes.com_error: (-2147221005, 'Ungültige Klassenzeichenfolge', None, None)
also a look at the registry shows that the object isn't registered.
I have no idea what I do wrong and would appreciate any help especially after applying the mentioned hotfix!
Best Regards
Hello mrathke,also a look at the registry shows that the object isn't registered
Applying Hotfix 5 (or later) to Zen Blue 2.6 is a must to use the COM interface.
You have to register the COM interface like
Code: Select all
cd "C:\Windows\Microsoft.NET\Framework64\v4.0.30319"
regasm /codebase /tlb "C:\Program Files\Carl Zeiss\ZEN 2\ZEN 2 (blue edition)\Zeiss.Micro.LM.Scripting.dll"
regasm /codebase /tlb "C:\Program Files\Carl Zeiss\ZEN 2\ZEN 2 (blue edition)\Zeiss.Micro.Scripting.dll"