Results 1 to 10 of 10

Thread: Com Interface with python

  1. #1
    Junior Member
    Join Date
    Jul 2015
    Posts
    1

    Question Com Interface with python

    Hello,

    some presentations (e.g. EuBias 2015) show how to use an external python script to access OAD functionallity using the COM interface.
    I tried this out based on the matlab description found here (http://forums.zeiss.com/microscopy/c...ead.php?t=1564)

    I use ZEN 2 desk (free download) and have the following problem:
    Registration of the dlls seems not to work. I get different errors (see attached files). I toggled the \codebase switch, but it did not make of a difference.

    My questions are:
    1) Are the any example scripts for python or tutorials to set up the COM interface for python (like the matlab tutorial linked above)
    2) I guess I need the Macro-extension to use the COM interface. Is there 90day trial version of the Macro-extension. I have a dongle which enables VBA scripting in zen black that comes with the same download, but it looks like that it does not affect the ZEN blue. On the other hand I could run some other examples, i.e. starting fiji from a macro to count cells.
    3) A TCP/IP example would also be great or description how to use setup Putty. I only get a blocked terminal "Welcome to ZEN PythonScript", input is not possible.

    Best regards,
    adama

    I added some files, including the error me
    Attached Files Attached Files

  2. #2

    Thumb up

    Adama, we are very sorry that out of reasons unknown your postings ended up in the moderation queue.

    A ZEISS support specialist will take care of your inquiry ASAP. Again, we are very sorry, please excuse the delay.
    ZEISS Microscopy
    Community Manager
    www.zeiss.com/microscopy
    microscopy@zeiss.com

  3. #3
    Hi,

    I just tested this with my ZEN2 system + Hotfix 5. When I run the BAT file to register the dlls I get some warnings, but no errors:


    Types un-registered successfully
    Type library 'C:\Program Files\Carl Zeiss\ZEN 2\ZEN 2 (blue edition)\Zeiss.Micro
    .Scripting.tlb' un-registered successfully
    Microsoft .NET Framework Assembly Registration Utility version 4.0.30319.34209
    for Microsoft .NET Framework version 4.0.30319.34209
    Copyright (C) Microsoft Corporation. All rights reserved.
    RegAsm : warning RA0000 : Registering an unsigned assembly with /codebase can ca
    use your assembly to interfere with other applications that may be installed on
    the same computer. The /codebase switch is intended to be used only with signed
    assemblies. Please give your assembly a strong name and re-register it.
    Types registered successfully
    Type library exporter warning processing 'Zeiss.Micro.Scripting.ProcessingSettin
    gs.FunctionWithChannelSetting.GetChannelDictionary (#0), Zeiss.Micro.Scripting'.
    Warning: Type library exporter encountered a generic type instance in a signatur
    e. Generic code may not be exported to COM.
    Assembly exported to 'C:\Program Files\Carl Zeiss\ZEN 2\ZEN 2 (blue edition)\Zei
    ss.Micro.Scripting.tlb', and the type library was registered successfully
    Microsoft .NET Framework Assembly Registration Utility version 4.0.30319.34209
    for Microsoft .NET Framework version 4.0.30319.34209
    Copyright (C) Microsoft Corporation. All rights reserved.
    Types un-registered successfully
    Type library 'C:\Program Files\Carl Zeiss\ZEN 2\ZEN 2 (blue edition)\Zeiss.Micro
    .LM.Scripting.tlb' un-registered successfully
    Microsoft .NET Framework Assembly Registration Utility version 4.0.30319.34209
    for Microsoft .NET Framework version 4.0.30319.34209
    Copyright (C) Microsoft Corporation. All rights reserved.
    RegAsm : warning RA0000 : Registering an unsigned assembly with /codebase can ca
    use your assembly to interfere with other applications that may be installed on
    the same computer. The /codebase switch is intended to be used only with signed
    assemblies. Please give your assembly a strong name and re-register it.
    Types registered successfully
    Type library exporter warning processing 'Zeiss.Micro.Scripting.Core.Deconvoluti
    onLM.Deconvolution(psfImages), Zeiss.Micro.LM.Scripting'. Warning: Type library
    exporter encountered a generic type instance in a signature. Generic code may no
    t be exported to COM.
    Assembly exported to 'C:\Program Files\Carl Zeiss\ZEN 2\ZEN 2 (blue edition)\Zei
    ss.Micro.LM.Scripting.tlb', and the type library was registered successfully
    Drücken Sie eine beliebige Taste . . .

    But I do not see any error inside the console output you attached inside the OAD.zip file.

    After registering the DLLs could control ZEN form MATLAB and from Python without any problems.

    I am not sure, but the problem could be that you need a valid OAD license for ZEN Blue in order to make this work. Are there any error messages in ZEN or MATLAB/Python?

    Attached you find some examples.

    Regarding the TCP/IP Example I would recommend open a separate thread.
    Attached Files Attached Files

  4. #4
    Junior Member
    Join Date
    Jun 2016
    Posts
    3

    Com Interface with python

    Hi,
    I see this thread is a little old, but it seems very closely related to my issues.

    I have Zen 2 (blue edition) installed and I am also looking to control it from Python 2.7 (canopy).
    Having followed the application note provided earlier in this thread- I believe I have successfully registered the Zen functionality with the .bat file (I get identical warning message to those posted).
    However, on trying to run a python test script to load the Zen Scripting API the following error is raised:
    com_error: (-2147221021, 'Operation unavailable', None, None)

    I have tried using comtypes in place of win32com however get the same problem.

    Any thoughts/suggestions would be much appreciated.
    Best,
    Chris

  5. #5
    Junior Member
    Join Date
    Jun 2016
    Posts
    3
    Just to append my earlier comment- I should say that Zen 2 is running and that I still get the same com error even if I'm running Canopy as Admin.
    Cheers,
    Chris

  6. #6
    CZ Administrators Carl Zeiss Microscopy 3's Avatar
    Join Date
    Jan 2013
    Posts
    357
    Hi Chris,

    before we go into more details please clarify that you have a valid OAD license, called ‘Macro Environment’, for ZEN blue. This license is needed for the COM Interface, the TCP Communication and of course for the Macro Environment itself. All these capabilities are conceptually very strongly linked so that they come in one package.

    The requirement to have a valid OAD license for ZEN blue cannot be substituted by any other license of ZEN blue or black.

    To help you in the context of OAD it is a good basis to know which licenses are active in your Zen blue application.

  7. #7
    Junior Member
    Join Date
    Jun 2016
    Posts
    3
    Apologise- I was under the impression that the Macro environment was part of our quote when purchasing Zen; however, on checking the available modules it would seem to not be the case!
    Cheers,
    Chris

  8. #8
    Junior Member
    Join Date
    Oct 2015
    Posts
    14

    Error with Excecute and Aquire Image

    I use ZEN blue Version 2.0 with a spinning disk and connect from Python 2.7.
    I can load an experiment:
    >>> experiment
    'AICS_4_Drubin.czexp'
    >>> exp = Zen.Acquisition.Experiments.GetByName(experiment)
    >>> exp.name
    u'AICS_4_Drubin.czexp'

    When I try to execute it I get an error message:
    >>> img = Zen.Acquisition.Execute(exp)
    Traceback (most recent call last):
    File "<input>", line 1, in <module>
    File "<COMObject <unknown>>", line 2, in Execute
    com_error: (-2147352567, 'Exception occurred.', (0, u'Zeiss.Micro.LM.Scripting', u'No licence for specified experiment dimension.', None, 0, -2146233079), None)

    >>> img = Zen.Acquisition.AcquireImage(exp)
    Traceback (most recent call last):
    File "<input>", line 1, in <module>
    TypeError: AcquireImage() takes exactly 1 argument (2 given)
    In the macro editor I get the same error for Execute, AcquireImage is working.

    Any ideas?
    Winfried

  9. #9
    Hi,

    so the COM Connection to python is OK, correct?

    The error sounds to me like a problem with the experiment itself. Which version of the ZEN software are you running.

    CZ6

  10. #10
    I just did a short check with ZEN 2.3 (latest release). At least the normal COM (the commands you used) stuff works a expected here. So I have the impression, that your experiment contains dimensions for which there is no license, which does not make sense, does it?

    Attached you find the respective IPython notebook.

    CZ6
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •