Skip to main content

Hello, I would like to use a macro to save images from Geometric Bitmap Image Analysis for different configuration.
I wrote this macro in ZPL to save the images obtained for different configurations but it doesn’t work:

! Read the # of configs
NCONFIG = NCON()
!Read path
settingfiles$ = "...\Zemax\Configs\IMB.CFG"

! Execute for each config
FOR i, 1, NCONFIG, 1
    ! Set config
    SETCONFIG i
    img_file$ = $STR(i) + ".png"
    MODIFYSETTINGS settingfiles$, GBM_OUTPUT, img_file$
    OPENANALYSISWINDOW "IBM"
    PAUSE THREADS
    
NEXT
PRINT "DONE!"

The configuration changes and the Geometric Bitmap Image Analysis window opens up and displays the right image but nothing is saved. Moreover, the output file name keeps the initial name and it isn’t modifying for each configuration. Do you have any idea to save those images ? (the folder path doesn’t matter)

 

I also wrote another ZPL macro which works and saves the image of the opened window following the different configuration but it still not really what I want since it’s not just the image itself that is saved.

Here the other macro:
! Read the # of configs
NCONFIG = NCON()

! Execute for each config
FOR i, 1, NCONFIG, 1
    ! Set config
    SETCONFIG i
    OPENANALYSISWINDOW "IBM"
    window = WINL()
    PAUSE THREADS
    img_path$ =  “...”
    filename$ = img_path$ + "\Red" + $STR(i)
    EXPORTBMP window, filename$     
NEXT
PRINT "DONE!"

 

Thank you in advance,

Hi Sedick,

The 2 things I would change about your code would be to include a FORMAT .0 before the FOR loop so the png file is an integer and then to include the CFG filename when using OPENANALYSISWINDOW:

SUSPENDUPDATES
cfg$ = $DATAPATH() + "\Configs\IMB.cfg"
FORMAT .0
FOR i = 1, NCON(), 1
SETCONFIG i
img$ = $STR(i) + ".png"
MODIFYSETTINGS cfg$, GBM_OUTPUT, img$
OPENANALYSISWINDOW "IBM", cfg$

PAUSE THREADS
CLOSEWINDOW WINL()
NEXT
RESUMEUPDATES

 


Hi Micheal, 


Thank you very much, it’s exactly what I want!

 

Sédick


Reply