Solved

Matlab API, ModifySettings error in POP

  • 7 August 2020
  • 2 replies
  • 135 views

Hi all,


I'm working with Matlab and trying to use the ModifySettings on a cfg file to update a Physical Optics Propagation analysis but continue to encounter an error. This is my setup so far:


 


TheSystem = TheApplication.PrimarySystem;


testFile = System.String.Concat('\\...\','myFile.zmx'); %the '...' is my directory


TheSystem.LoadFile(testFile,false);


pop = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.PhysicalOpticsPropagation);


pop.Terminate();


pop.WaitForCompletion();


pop_setting = pop.GetSettings();


cfg = System.String.Concat('\\...\','myCFG.cfg');


pop_setting.LoadFrom(cfg);


pop_setting.ModifySettings(cfg, 'POP_PARAM1', 0.010) %Beam Waist in X. 


 


This last line is where I get my error: 'No method 'ModifySettings' with matching signature found for class 'ZemaxUI.ZOSAPI.Analysis.AS_Default'.' The idea is to run a number of POP analyses for different beam waists, so being able to update the beam waist is necessary. Any help would be appreciated.


 


Thanks

icon

Best answer by Csilla Timar-Fulep 7 August 2020, 13:15

View original

2 replies

Hello Csilla,


Thank you for your help, this worked perfectly! I must have missed the that the newValue was a string input in the documentation. I was also looking at the 'ZOS-API using Python' knowledgebase ('# 2.5 Modify Settings Method' section) and the post did not rely on string input for the newValue. 


Thanks again! 

Userlevel 5
Badge +2

Hello Cesar,

 

Thanks for your question here!

 

 

As discussed in this knowledge base article Basic method of performing system analysis in ZOS-API, there are in general 2 ways that analysis settings can be adjusted. Firstly, some commonly-used analyses have analysis-specific settings interfaces available. An example is IAS_FftMtf. In these cases, all the analysis settings interfaces are located in the ZOSAPI.Analysis.Settings Namespace. You can check if your analysis has a settings interface using the HasAnalysisSpecificSettings property:

 

 

my_analysis.HasAnalysisSpecificSettings

 

Unfortunately, for POP the command returns “0”, which means that the analysis does not have a fully-implemented settings interface available. Therefore the analysis settings cannot be edited via the API but have to be changed through the second option, which is via the IAS_ModifySettings command, which modifies the settings file for the analysis (.cfg file) directly:

 

 

The ModifySettings command works very similarly to the ZPL MODIFYSETTINGS keyword, you may find more info in the Help file under:

The Programming Tab > About the ZPL > KEYWORDS (about the zpl) > MODIFYSETTINGS (keywords)

 

 

The ModifySettings function and keyword need string inputs, even the new value has to be a string. The problem with your code is that the entered new value is not a string variable. If you change the last line of your code as one of the followings, it will work fine:

 

 

pop_setting.ModifySettings(cfg, 'POP_PARAM1', num2str(0.010)) %Beam Waist in X.

 

 

or

 

 

pop_setting.ModifySettings(cfg, 'POP_PARAM1', '0.010') %Beam Waist in X.

 

 

 

 

 

If you have further questions, please let us know and we will be happy to help!

 

 

Best,

 

 

Csilla

 

Reply