Solved

# A question about create automatically optimization wizard table by ZPL

• 2 replies
• 183 views

Hi

I'm trying coding a ZPL script to create an automatic optimization wizard table.

My target optimization wizard table was show as below picture.

Here is producing optimization wizard table by running my ZPL script.

Unfortunately, they have three differences by comparing the two created optimization wizard tables and making numbers on the above pictures.

Here is a list of the parameter value for differences.

This is show the partial screenshot of my ZPL script, the code also attached to set Merit Function.zip.

What kind the command settings/paraments were missing in this ZPL script? That can be fixed for the three differences.

Hi ChiaWei,

After investigating your macro, I can’t figure out an answer, but here’s what I can say.

### Regarding Red Box 1

I’m not sure why X Wgt is reported as Inf, but one thing I noted is that by changing the value of xw in your code, Y Wgt is updated in the BLNK line below DMFS. In fact, Y Wgt becomes equal to one over X Wgt, which sort of makes sense. If you have a value of xw of 5.0, and hypothetically, the X Weight stays at 1.0, then the Y Weight has to be 1.0 / 5.0 = 0.2, and so the x component is given a weight five times higher effectively.

### Regarding Red Box 2

I don’t know why you have a value of 4.0 for all your weights, but since they are all the same, it shouldn’t matter what this value is. You could also change the value of ow to be 1.0 / 4.0 = 0.25, and the weights should go back to 1.0. It is still strange that they are not 1.0 to begin with (I’m assuming the Overall Weight of the Merit Function you define by hand is 1.0), but it shouldn’t make a difference in terms of the Merit Function result.

### Regarding Red Box 3

It seems like your code doesn’t delete the vignetted ray operands. I noted that you’ve used delOrNot = -1. However, -1 is not a valid value, it has to be either 0 (to not delete vignetted rays) or 1 (to delete vignetted rays). Can you try to change your -1 to 1 and see if it makes a difference?

Lastly, this can also be done with the ZOS-API and the Inf issue isn’t appearing there. I’ve made a Python example for you that you can insert in a template code for interactive extension or standalone application (Programming..Python..Standalone Application / Interactive Extension):

# Remove all operands in the MFE
TheSystem.MFE.RemoveOperandsAt(1, TheSystem.MFE.NumberOfOperands)

# Open the MFE Wizard
MFEWizard = TheSystem.MFE.SEQOptimizationWizard2

# Change MFE Wizard settings
MFEWizard.Criterion = ZOSAPI.Wizards.CriterionTypes.Spot
MFEWizard.XSWeight = 1.0
MFEWizard.YTWeight = 1.0
MFEWizard.Type = ZOSAPI.Wizards.OptimizationTypes.RMS
MFEWizard.Reference = ZOSAPI.Wizards.ReferenceTypes.Centroid
MFEWizard.GridSizeNxN = 4
MFEWizard.DeleteVignetted = True
MFEWizard.AssumeAxialSymmetry = True
MFEWizard.IgnoreLateralColor = False
MFEWizard.StartAt = 1
MFEWizard.OverallWeight = 1.0

# Apply MFE Wizard
MFEWizard.Apply()

The Wizard has more settings available through the ZOS-API as shown below (frome the Syntax Help File):

I hope this helps. Take care,

David

ZOS-API is very powerful, I have used it to replace the macro for a long time.

but, there are some small corners where macros must be used, such as solve of ZPL,