Coder Social home page Coder Social logo

No function to export jpg to file PyZDDE about pyzdde HOT 5 CLOSED

 avatar commented on September 15, 2024
No function to export jpg to file PyZDDE

from pyzdde.

Comments (5)

 avatar commented on September 15, 2024

I've solved the issue by continuously renaming the saved .jpg file via python itself, it's not pretty but it works. Maybe there's a better way to do this, but I'm happy for now:)

from pyzdde.

indranilsinharoy avatar indranilsinharoy commented on September 15, 2024

Hi @Toniostado,

I am sorry that I couldn't respond to you earlier. The ipzCaptureWindow() function was designed to work in an IPython environment only. The ipzCaptureWindow() function internally uses GetMetaFile DDE command, which Zemax has removed in recent versions of OpticStudio. So, going forward, I imagine that the only way to dump images automatically from Zemax is by using macros (which I don't really like myself exactly because of the limitations that you have mentioned).
Also, you are right that one cannot change the macro to specify a filename, etc. That is a limitation imposed by Zemax, unfortunately, and so we probably cannot do much about it from PyZDDE.
I am not sure if there is any other more efficient way to circumvent this problem other than what you have done.
Since, you seem to have resolved your problem for now, I will go ahead and close this issue.

from pyzdde.

shbhuk avatar shbhuk commented on September 15, 2024

I am trying to do the same thing, however when I try to ExecuteZPLMacro('xyz') I get either -999 or -1 return code.

I am able to use the 'CALL MACRO' operand in Zemax and run the secondary macro, but unable to do so in PyZDDE

from pyzdde.

indranilsinharoy avatar indranilsinharoy commented on September 15, 2024

@shbhuk The errors you are seeing could be due to a couple of reasons. Where does the zpl macro file which you are trying to execute reside? Is it in the default location (i.e. in C:\Users\xxx\Documents\Zemax\Macros)? If not then you got to do two things:

  1. Change the folder location in Zemax (Setup >> Project Preferences >> Folders >> ZPL) to the appropriate location, and also
  2. Use the PyZDDE function zSetMacroPath() to set the macro path to the same folder as 1.

See the example below (I just executed in Jupyter Console and OpticStudio 16.5):

from pyzdde.

shbhuk avatar shbhuk commented on September 15, 2024

The .zpl file is in the default Macro location.

from pyzdde.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.