Page 1 of 1

Zen.Application.LoadImage through python COM interface

Posted: Sun Jul 14, 2019 3:13 am
by user-6944
Hi,

I'm trying to load an image into Zen Blue using the python COM interface with this code:

Code: Select all

import win32com.client
Zen = win32com.client.GetActiveObject("Zeiss.Micro.Scripting.ZenWrapperLM")
Zen.Application.LoadImage('C:/test.tiff')
and get the following error:

Code: Select all

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-32-7115728bee1f> in <module>
      1 import win32com.client
      2 Zen = win32com.client.GetActiveObject("Zeiss.Micro.Scripting.ZenWrapperLM")
----> 3 Zen.Application.LoadImage('C:/test.tiff')

TypeError: LoadImage() takes 1 positional argument but 2 were given
Can you provide me with example code how to load an image into Zen using the COM interface?

Thanks,

Johannes

Posted: Mon Jul 15, 2019 10:34 am
by user-4
Hello jelferich,

first of all the error message is a bit misleading.

So
LoadImage() takes 1 positional argument but 2 were given
should be
LoadImage() takes 0 positional argument but 1 is given

Python has an internal 'this' as a parameter, which is also counted.

As already said in this forum, COM has no 'Function Overloading'.

To overcome this problem, COM uses underscore plus a number added to the function e.g. LoadImage_2

So in your case

im = Zen.Application.LoadImage_2('C:\\test.tiff')

should work ;-)

How to load a czi file through the Matlab com interface?

Posted: Thu Dec 26, 2019 3:28 pm
by user-7180
Hi,

I want to load a czi file through Matlab com interface, can you provide a demo script to do this? My Zen version is black version 2012. Thank you very much.

Posted: Fri Jan 24, 2020 10:10 am
by user-4
Sorry for the late reply, but this is a forum for Zen blue only.
Therefore I had to organize some description:

COM interface (Zen Black)
The full range of ZEN VBA commands is also available via COM, by connecting a client program to a running ZEN system. There are two COM-automation objects available, for the Lsm5Vba interface and for the VBA-GUI interface. The COM object Lsm5Vba is called "Lsm5Vba.Application", and the one for the VBA-GUI interface is called "Zeiss.Micro.AIM.ApplicationInterface".

For example to connect a MATLAB session to ZEN, start ZEN first, start MATLAB, and then type
ZENVBA = actxGetRunningServer('Lsm5Vba.Application')
ZEN = actxGetRunningServer('Zeiss.Micro.AIM.ApplicationInterface.ApplicationInterface')


To start a scan, two commands are now available
ZENVBA.Lsm5.StartScan
ZEN.GUI.Acquisition.Snap.Execute


It sounds to me that you need the Zen black VBA module to work with the COM-interface.
Please contact your local ZEISS sales or support people for further information.

Re: Zen.Application.LoadImage through python COM interface

Posted: Mon Aug 24, 2020 2:21 pm
by AK Veeraraghavan
when running :

Zen = win32com.client.GetActiveObject("Zeiss.Micro.Scripting.ZenWrapperLM")

I am getting the error :

com_error Traceback (most recent call last)
<ipython-input-12-893d5517d59c> in <module>
----> 1 Zen = win32com.client.GetActiveObject("Zeiss.Micro.Scripting.ZenWrapperLM")

~\Anaconda3\envs\cadnavigation\lib\site-packages\win32com\client\__init__.py in GetActiveObject(Class, clsctx)
77 """
78 resultCLSID = pywintypes.IID(Class)
---> 79 dispatch = pythoncom.GetActiveObject(resultCLSID)
80 dispatch = dispatch.QueryInterface(pythoncom.IID_IDispatch)
81 return __WrapDispatch(dispatch, Class, resultCLSID = resultCLSID, clsctx = clsctx)

com_error: (-2147221021, 'Operation unavailable', None, None)

I am not sure how to resolve it. Can someone help me with fixing this.

Re: Zen.Application.LoadImage through python COM interface

Posted: Thu Oct 15, 2020 1:42 pm
by CarlZeissMicroscopy3
Did you manage to get it running?

Most probably the COM interface has not been registered via 'regasm'.

Re: Zen.Application.LoadImage through python COM interface

Posted: Fri Oct 20, 2023 12:41 pm
by Danial Bunkla
AK Veeraraghavan wrote: Mon Aug 24, 2020 2:21 pm when running :555 meaning sexually
444 meaning sexually
Zen = win32com.client.GetActiveObject("Zeiss.Micro.Scripting.ZenWrapperLM")
seeing 1111 when thinking of ex
I am getting the error :

com_error Traceback (most recent call last)
<ipython-input-12-893d5517d59c> in <module>
----> 1 Zen = win32com.client.GetActiveObject("Zeiss.Micro.Scripting.ZenWrapperLM")

~\Anaconda3\envs\cadnavigation\lib\site-packages\win32com\client\__init__.py in GetActiveObject(Class, clsctx)
77 """
78 resultCLSID = pywintypes.IID(Class)
---> 79 dispatch = pythoncom.GetActiveObject(resultCLSID)
80 dispatch = dispatch.QueryInterface(pythoncom.IID_IDispatch)
81 return __WrapDispatch(dispatch, Class, resultCLSID = resultCLSID, clsctx = clsctx)

com_error: (-2147221021, 'Operation unavailable', None, None)

I am not sure how to resolve it. Can someone help me with fixing this.
Try this:

Code: Select all

import win32com.client

try:
    Zen = win32com.client.GetActiveObject("Zeiss.Micro.Scripting.ZenWrapperLM")
except Exception as e:
    print(f"An error occurred: {e}")
Remember to replace the placeholder "Zeiss.Micro.Scripting.ZenWrapperLM" with the actual Class ID if it's different.

Re: Zen.Application.LoadImage through python COM interface

Posted: Thu Nov 02, 2023 7:04 pm
by Jaque Vivier
@Danial Bunkla, Thank you very much for your response! It was extremely helpful

Re: Zen.Application.LoadImage through python COM interface

Posted: Mon Dec 25, 2023 5:30 pm
by Ibrahim Sultan
The System Development Life Cycle (SDLC) intricately navigates the journey of software creation, encompassing distinct phases crucial for seamless development. Starting with planning and requirements gathering, SDLC progresses through design, implementation, testing, deployment, and maintenance, ensuring a structured approach to software development. Each phase plays a pivotal role in crafting reliable, efficient, and user-centric applications. Understanding these phases is vital for software professionals and enthusiasts alike. Dive deeper into the SDLC phases and their significance at Intellectsoft, unraveling the systematic process behind successful software development.