Hi everybody,
I need your advice / help for using the API.
I am currently trying to run my Zemax file over the interactive mode with python. So far, I have managed with the help of the ZOS-API Syntax help and the examples presented there, but I am not getting any further at this point.
The Zemax file I want to control is a non-sequential system.
I would like to create a Universal 1-D Plot where I plot the value of one operand (=NSDD) in my merit function in dependence of the tilt angle of an object in my system. In the image attached at the bottom you can see the settings I would like to set over python.
I am struggling with setting the field “NSC Data” with python. In the documentation under KEYWORDS-->MODIFYSETTINGS I cannot find any setting for this option:
UN1_CATEGORY: Use 0 for surface, 1 for system, 2 for config. |
I tried 3 for “NSC data” without success. You can find the python snippet I used below.
My question boiled down:
Is there a way to set the NSC category in an universal 1-D plot over python?
I workaround for me would be to open/load a predefined universal 1D plot with the correct settings. (I think that would be a .UPL file?)
Thanks in advance for any feedback or hint :)
Best,
Matteo
Python snippet:
print("Trying to create a universal 1-D plot with NSC data")
UnivPlot = TheSystem.Analyses.New_Analysis_SettingsFirst(constants.AnalysisIDM_UniversalPlot1D)
UnivPlot.Terminate()
UnivPlot.WaitForCompletion()
UnivPlot_Settings = UnivPlot.GetSettings()
UnivPlot_Set = CastTo(UnivPlot_Settings, "IAS_") # Cast settings to IAS_ interface
print("Universal Plot has analysis specific settings? ", UnivPlot.HasAnalysisSpecificSettings)
# Above is False; Universal Plot Settings must be changed via ModifySettings (changing a config (.cfg) file)
cfg = TheApplication.ZemaxDataDir + "\\Configs\\UNI_MATTEO.CFG"
UnivPlot_Set.SaveTo(cfg) # Create new .cfg file, named "UNI.CFG" in \Configs\ folder
UnivPlot_Set.ModifySettings(cfg, 'UN1_CATEGORY', 1)
# from KEYWORDS-> MODIFYSETTINGS:
# UN1_CATEGORY: Use 0 for surface, 1 for system, 2 for config
# What is the category for NSC data??
UnivPlot_Set.ModifySettings(cfg, 'UN1_STARTVAL', -25)
UnivPlot_Set.ModifySettings(cfg, 'UN1_STOPVAL', 25)
UnivPlot_Set.ModifySettings(cfg, 'UN1_STEPS', 4)
UnivPlot_Set.ModifySettings(cfg, 'UN1_MFLINE', 3)
UnivPlot_Set.ModifySettings(cfg, 'UN1_PAR1', 1)
UnivPlot_Set.ModifySettings(cfg, 'UN1_PAR3', 3)
UnivPlot_Set.Save()
# Run the analysis with the new settings
UnivPlot_Set = CastTo(UnivPlot, 'IA_')
UnivPlot_Set.ApplyAndWaitForCompletion()
![](https://uploads-us-west-2.insided.com/zemax-en/attachment/8b0d94b5-5d37-4b0c-8a6a-280a4f3ef0da.png)
![](https://uploads-us-west-2.insided.com/zemax-en/attachment/c64972a5-0e4a-4d6d-b5a2-7237c77c88e3.png)