Hi Vincent,
Before I get to answer your questions. I’d like to mention that depending how complex you want the macro to be, it might be worth considering the ZOS-API, which should give you more flexibility.
These are my answers to your questions:
- Changing a surface Thickness and Parameter 1 in a loop. You can use the SETSURFACEPROPERTY or SURP keyword to modify the Thickness and Parameter 1 of a surface. I’m showing how to do so in a loop below:
# Surface to be modified
surface_number = 1
# Codes for the SURP keyword (check Help File for more details)
thickness_code = 3
parameter_code = 10 # This is the code for the parameters
parameter_number_code = 1 # This is the code for Parameter 1
# Loop
FOR index, 0, 10, 1
# Calculate new thickness and Parameter 1
new_thickness = index
new_parameter = index
# Update the lens data with the new values
SURP surface_number, thickness_code, new_thickness
SURP surface_number, parameter_code, new_parameter, parameter_number_code
NEXT
- Setting a variable surface parameter. This is doen with the SOLVETYPE keyword. I let you read the Help File (F1) to understand what codes you need. For Thickness and Parameter 1 you need the following lines (assuming surface_number has been defined like above):
SOLVETYPE surface_number, TV
SOLVETYPE surface_number, PV_1
- If you need to remove the variable solve for the Thickness and Parameter 1 you need the following lines:
SOLVETYPE surface_number, TF
SOLVETYPE surface_number, PF_1
- Running an optimization. To run an optimization, you need the OPTIMIZE keyword and you can specify the number of cycles like so:
OPTIMIZE number_of_cylces
- Adding an operand. In case you’d want to setup POPD through ZPL (assuming your POP analysis settings have been saved properly, check the Help File about POPD). I would do it like so:
# Row at which the operand is inserted
row_number = 1
# New operand
INSERTMFO row_number
# New operand settings
popd_surface = 1
popd_wave = 1
popd_field = 1
popd_data = 0
popd_target = 0.5
popd_weight = 1.0
# Set new operand
SETOPERAND row_number, 11, "POPD"
SETOPERAND row_number, 2, popd_surface
SETOPERAND row_number, 3, popd_wave
SETOPERAND row_number, 4, popd_field
SETOPERAND row_number, 5, popd_data
SETOPERAND row_number, 8, popd_target
SETOPERAND row_number, 9, popd_weight
I believe you have everything to get started with your macro, let me know if you have any other question and if everything makes sense.
Take care,
David