Skip to main content

ZOS-API interface 2024 R2 SP02

ZOSAPI.Analysis.Settings.IAS_ Interface Reference

Last update: 17.07.2025

Base class for all analysis settings interfaces. This class can be accessed via the IA_ interface. More...

Inheritance diagram for ZOSAPI.Analysis.Settings.IAS_:

Public Member Functions

IMessages Verify ()
 
void Save ()
 Saves the current settings to the default CFG file.
 
void Load ()
 Loads settings from the default CFG file.
 
void Reset ()
 Resets the settings back to the defaults for the current analysis.
 
bool SaveTo (string settingsFile)
 Saves the current settings to the specified file.
 
bool LoadFrom (string settingsFile)
 Replaces the current settings with settings read from the specified file.
 
bool ModifySettings (string settingsFile, string typeCode, string newValue)
 Changes a single setting in the specified file. See the MODIFYSETTINGS DDE command help documentation for more information.
 

Detailed Description

Base class for all analysis settings interfaces. This class can be accessed via the IA_ interface.

Usage (see Example 15 for a full sample)

C#

//Open a shaded model
IA_ analysis = TheSystem.Analyses.New_Analysis(AnalysisIDM.ShadedModel);
analysis.Terminate();
analysis.WaitForCompletion();
IAS_ analysisSettings = analysis.GetSettings();
string cfgFile = System.IO.Path.GetTempFileName();
// Save the current settings to the temp file
analysisSettings.SaveTo(cfgFile);
// make your modifications to it
//MODIFYSETTINGS are defined in the ZPL help files: The Programming Tab > About the ZPL > Keywords
analysisSettings.ModifySettings(cfgFile, "SHA_ROTX", "90");
analysisSettings.ModifySettings(cfgFile, "SHA_ROTY", "0");
analysisSettings.ModifySettings(cfgFile, "SHA_ROTZ", "0");
// now load in the modified settings
analysisSettings.LoadFrom(cfgFile);
// If you want to overwrite your default CFG, copy it after you are done modifying the settings:
//string CFG_fullname = System.Environment.GetEnvironmentVariable("USERPROFILE") + "\\Documents\\Zemax\\Configs\\Configs\\POP.CFG";
//System.IO.File.Copy(cfgFile, CFG_fullname, true);
// We don't need the temp file any more, so delete it
System.IO.File.Delete(cfgFile);
// Run the analysis with the new settings
Base interface for all analysis windows. This interface can be accessed via the I_Analyses interface.
Definition: IA_Base.cs:29
bool Terminate()
Attempt to cancel the currently running the analysis.
void WaitForCompletion()
Waits for the current analysis to finish running (if applicable).
IAS_ GetSettings()
Gets the settings for the current analysis.
IMessage ApplyAndWaitForCompletion()
Re-runs the analysis with the current settings and waits for it to finish calculating.
Base class for all analysis settings interfaces. This class can be accessed via the IA_ interface.
Definition: IAS_Base.cs:25
bool ModifySettings(string settingsFile, string typeCode, string newValue)
Changes a single setting in the specified file. See the MODIFYSETTINGS DDE command help documentation...
bool SaveTo(string settingsFile)
Saves the current settings to the specified file.
bool LoadFrom(string settingsFile)
Replaces the current settings with settings read from the specified file.
AnalysisIDM
All available analysis types. See the I_Analyses interface for more information.
Definition: I_Analyses.cs:15

C++

// Open a shaded model
IA_Ptr analysis = TheSystem->Analyses->New_Analysis(AnalysisIDM::AnalysisIDM_ShadedModel);
analysis->Terminate();
analysis->WaitForCompletion();
IAS_Ptr settings = analysis->GetSettings();
//need to use - #pragma warning(disable:4996)
char* pUserprofile = getenv("Temp");
_bstr_t cfgFile = _bstr_t(pUserprofile) + "\\sha.cfg";
// Save the current settings to the temp file
settings->SaveTo(cfgFile);
// make your modifications to it
// MODIFYSETTINGS are defined in the ZPL help files : The Programming Tab > About the ZPL > Keywords
settings->ModifySettings(cfgFile, "SHA_ROTX", "90");
settings->ModifySettings(cfgFile, "SHA_ROTY", "0");
settings->ModifySettings(cfgFile, "SHA_ROTZ", "0");
// now load in the modified settings
settings->LoadFrom(cfgFile);
// If you want to overwrite your default CFG, copy it after you are done modifying the settings :
//_bstr_t CFG_fullname = _bstr_t(getenv("USERPROFILE")) + "\\Documents\\Zemax\\Configs\\POP.CFG";
// copyfile(cfgFile, CFG_fullname) // generic psuedo code
// We don't need the temp file any more, so delete it
std::remove(cfgFile);
// Run the analysis with the new settings
analysis->ApplyAndWaitForCompletion();

Matlab

%Open a shaded model
analysis = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.ShadedModel);
analysis.Terminate();
analysis.WaitForCompletion();
analysisSettings = analysis.GetSettings();
cfgFile = System.IO.Path.GetTempFileName();
% Save the current settings to the temp file
analysisSettings.SaveTo(cfgFile);
% make your modifications to it
%MODIFYSETTINGS are defined in the ZPL help files: The Programming Tab > About the ZPL > Keywords
analysisSettings.ModifySettings(cfgFile, 'SHA_ROTX', '90');
analysisSettings.ModifySettings(cfgFile, 'SHA_ROTY', '0');
analysisSettings.ModifySettings(cfgFile, 'SHA_ROTZ', '0');
% now load in the modified settings
analysisSettings.LoadFrom(cfgFile);
% If you want to overwrite your default CFG, copy it after you are done modifying the settings:
%string CFG_fullname = System.Environment.GetEnvironmentVariable("USERPROFILE") + "\\Configs\\POP.CFG";
%System.IO.File.Copy(cfgFile, CFG_fullname, true);
% We don't need the temp file any more, so delete it
System.IO.File.Delete(cfgFile);
% Run the analysis with the new settings
analysis.ApplyAndWaitForCompletion();
Definition: IAS_FieldCurvatureAndDistortion.cs:5
The ZOSAPI namespace contains classes for initially connecting to zemax. See also ZOSAPI_Connection,...
Definition: IAS_FieldCurvatureAndDistortion.cs:5

Python

# Open a shaded model
analysis = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.ShadedModel)
analysis.Terminate()
analysis.WaitForCompletion()
analysisSettings = analysis.GetSettings()
cfgFile = os.environ.get('Temp') + '\\sha.cfg'
# Save the current settings to the temp file
analysisSettings.SaveTo(cfgFile)
# make your modifications to it
# MODIFYSETTINGS are defined in the ZPL help files: The Programming Tab > About the ZPL > Keywords
analysisSettings.ModifySettings(cfgFile, 'SHA_ROTX', '90')
analysisSettings.ModifySettings(cfgFile, 'SHA_ROTY', '0')
analysisSettings.ModifySettings(cfgFile, 'SHA_ROTZ', '0')
# now load in the modified settings
analysisSettings.LoadFrom(cfgFile)
# If you want to overwrite your default CFG, copy it after you are done modifying the settings:
# CFG_fullname = os.environ.get('USERPROFILE') + '\\Documents\\Zemax\\Configs\\POP.CFG'
# copyfile(cfgFile, CFG_fullname)
# We don't need the temp file any more, so delete it
if os.path.exists(cfgFile):
os.remove(cfgFile)
# Run the analysis with the new settings
analysis.ApplyAndWaitForCompletion()
Examples
CSharpStandalone_11_Basic_Seq.cs, CSharpStandalone_15_Seq_Optimization.cs, and CSharpStandalone_17_NSC_BulkScatter.cs.

Member Function Documentation

◆ Load()

void ZOSAPI.Analysis.Settings.IAS_.Load ( )

Loads settings from the default CFG file.

◆ LoadFrom()

bool ZOSAPI.Analysis.Settings.IAS_.LoadFrom ( string  settingsFile)

Replaces the current settings with settings read from the specified file.

Usage (see Example 17 for a full sample)

C#

//Open a detector viewer
analysis = TheSystem.Analyses.New_Analysis(AnalysisIDM.DetectorViewer);
analysisSettings = analysis.GetSettings();
cfgFile = System.IO.Path.GetTempFileName();
analysisSettings.SaveTo(cfgFile);
analysisSettings.ModifySettings(cfgFile, "DVW_SHOW", "2");
analysisSettings.ModifySettings(cfgFile, "DVW_SMOOTHING", "1");
analysisSettings.LoadFrom(cfgFile);
System.IO.File.Delete(cfgFile);
analysis.ApplyAndWaitForCompletion();

C++

//Open a detector viewer
analysis = TheSystem->Analyses->New_Analysis(AnalysisIDM_DetectorViewer);
analysisSettings = analysis->GetSettings();
tmpnam_s(cfgFile, L_tmpnam_s);
analysisSettings->SaveTo(cfgFile);
analysisSettings->ModifySettings(cfgFile, "DVW_SHOW", "2");
analysisSettings->ModifySettings(cfgFile, "DVW_SMOOTHING", "1");
analysisSettings->LoadFrom(cfgFile);
remove(cfgFile);
analysis->ApplyAndWaitForCompletion();

Matlab

% Open a detector viewer
det_analysis = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.DetectorViewer);
det_analysisSettings = det_analysis.GetSettings();
det_cfgFile = System.String.Concat(SamplesFolder, '\API\Matlab\e17_DetectorViewer.cfg');
det_analysisSettings.SaveTo(det_cfgFile);
det_analysisSettings.ModifySettings(det_cfgFile, 'DVW_SHOW', '2');
det_analysisSettings.ModifySettings(det_cfgFile, 'DVW_SMOOTHING', '1');
det_analysisSettings.LoadFrom(det_cfgFile);
det_analysis.ApplyAndWaitForCompletion();

Python

# Open a detector viewer
det_analysis = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.DetectorViewer)
det_analysisSettings = det_analysis.GetSettings()
det_cfgFile = SamplesFolder + "\\API\\Python\\e17_DetectorViewer.cfg"
det_analysisSettings.SaveTo(det_cfgFile)
det_analysisSettings.ModifySettings(det_cfgFile, "DVW_SHOW", "2")
det_analysisSettings.ModifySettings(det_cfgFile, "DVW_SMOOTHING", "1")
det_analysisSettings.LoadFrom(det_cfgFile)
det_analysis.ApplyAndWaitForCompletion()
Parameters
settingsFileThe settings file.
Returns
Examples
CSharpStandalone_11_Basic_Seq.cs, CSharpStandalone_15_Seq_Optimization.cs, and CSharpStandalone_17_NSC_BulkScatter.cs.

◆ ModifySettings()

bool ZOSAPI.Analysis.Settings.IAS_.ModifySettings ( string  settingsFile,
string  typeCode,
string  newValue 
)

Changes a single setting in the specified file. See the MODIFYSETTINGS DDE command help documentation for more information.

Usage (see Example 17 for a full sample)

C#

//Open a shaded model
IA_ analysis = TheSystem.Analyses.New_Analysis(AnalysisIDM.NSCShadedModel);
analysis.Terminate();
analysis.WaitForCompletion();
IAS_ analysisSettings = analysis.GetSettings();
string cfgFile = System.IO.Path.GetTempFileName();
// Save the current settings to the temp file
analysisSettings.SaveTo(cfgFile);
// make your modifications to it
//MODIFYSETTINGS are defined in the ZPL help files: The Programming Tab > About the ZPL > Keywords
analysisSettings.ModifySettings(cfgFile, "SHA_ROTX", "20");
analysisSettings.ModifySettings(cfgFile, "SHA_ROTY", "-20");
analysisSettings.ModifySettings(cfgFile, "SHA_ROTZ", "30");
// now load in the modified settings
analysisSettings.LoadFrom(cfgFile);
// If you want to overwrite your default CFG, copy it after you are done modifying the settings:
//string CFG_fullname = "\\zmedc02\\users\\sandrine.auriol\\Documents\\Zemax\\Configs\\POP.CFG";
//System.IO.File.Copy(cfgFile, CFG_fullname, true);
// We don't need the temp file any more, so delete it
System.IO.File.Delete(cfgFile);
// Run the analysis with the new settings

C++

//Open a shaded model
IA_Ptr analysis = TheSystem->Analyses->New_Analysis(AnalysisIDM_NSCShadedModel);
analysis->Terminate();
analysis->WaitForCompletion();
IAS_Ptr analysisSettings = analysis->GetSettings();
char cfgFile[L_tmpnam_s];
tmpnam_s(cfgFile, L_tmpnam_s);
// Save the current settings to the temp file
analysisSettings->SaveTo(cfgFile);
// make your modifications to it
// MODIFYSETTINGS are defined in the ZPL help files: The Programming Tab > About the ZPL > Keywords
analysisSettings->ModifySettings(cfgFile, "SHA_ROTX", "20");
analysisSettings->ModifySettings(cfgFile, "SHA_ROTY", "-20");
analysisSettings->ModifySettings(cfgFile, "SHA_ROTZ", "30");
// now load in the modified settings
analysisSettings->LoadFrom(cfgFile);
// We don't need the temp file any more, so delete it
remove(cfgFile);
// Run the analysis with the new settings
analysis->ApplyAndWaitForCompletion();

Matlab

% Open a shaded model
analysis = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.NSCShadedModel);
analysis.WaitForCompletion();
analysisSettings = analysis.GetSettings();
cfgFile = char(System.String.Concat(SamplesFolder, '\API\Matlab\e17_NSC_BulkScatter.cfg'));
analysisSettings.SaveTo(cfgFile); % Save current settings to a cfg file
% MODIFYSETTINGS are defined in ZPL help files: The Programming Tab > About the ZPL > Keywords
% need to manually turn on SCATTERING in shaded model to see bulk scattering
analysisSettings.ModifySettings(cfgFile, 'SHA_ROTX', '20');
analysisSettings.ModifySettings(cfgFile, 'SHA_ROTY', '-20');
analysisSettings.ModifySettings(cfgFile, 'SHA_ROTZ', '30');
analysisSettings.LoadFrom(cfgFile); % Load in the newly modified settings
% If you want to overwrite your default CFG, save over it with newly modified CFG file:
% CFG_fullname = System.String.Concat(getenv('Temp'), '\Documents\Zemax\Configs\LSN.CFG');
% copyfile(char(cfgFile), char(CFG_fullname));
analysis.ApplyAndWaitForCompletion(); % Run analysis

Python

# Open a shaded model
analysis = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.NSCShadedModel)
analysis.WaitForCompletion()
analysisSettings = analysis.GetSettings()
cfgFile = SamplesFolder + "\\API\\Python\\e17_NSC_BulkScatter.cfg"
analysisSettings.SaveTo(cfgFile) # Save current settings to a cfg file
# MODIFYSETTINGS are defined in ZPL help files: The Programming Tab > About the ZPL > Keywords
analysisSettings.ModifySettings(cfgFile, "SHA_ROTX", "20")
analysisSettings.ModifySettings(cfgFile, "SHA_ROTY", "-20")
analysisSettings.ModifySettings(cfgFile, "SHA_ROTZ", "30")
analysisSettings.LoadFrom(cfgFile) # Load in the newly modified settings
# If you want to overwrite your default CFG, save over it with newly modified CFG file:
# CFG_fullname = "C:\\Users\\zachary.Derocher\\Documents\\Zemax\\Configs\\POP.CFG"
# import shutil
# shutil.copy(cfgFile, CFG_fullname)
analysis.ApplyAndWaitForCompletion() # Run analysis
Parameters
settingsFileThe settings file.
typeCodeThe type code.
newValueThe new value.
Returns
Examples
CSharpStandalone_11_Basic_Seq.cs, CSharpStandalone_15_Seq_Optimization.cs, and CSharpStandalone_17_NSC_BulkScatter.cs.

◆ Reset()

void ZOSAPI.Analysis.Settings.IAS_.Reset ( )

Resets the settings back to the defaults for the current analysis.

Implemented in ZOSAPI.Analysis.Tolerancing.IAS_ISOElementDrawing.

◆ Save()

void ZOSAPI.Analysis.Settings.IAS_.Save ( )

Saves the current settings to the default CFG file.

Examples
CSharpStandalone_11_Basic_Seq.cs.

◆ SaveTo()

bool ZOSAPI.Analysis.Settings.IAS_.SaveTo ( string  settingsFile)

Saves the current settings to the specified file.

Usage (see Example 17 for a full sample)

C#

//Open a detector viewer
analysis = TheSystem.Analyses.New_Analysis(AnalysisIDM.DetectorViewer);
analysisSettings = analysis.GetSettings();
cfgFile = System.IO.Path.GetTempFileName();
analysisSettings.SaveTo(cfgFile);
analysisSettings.ModifySettings(cfgFile, "DVW_SHOW", "2");
analysisSettings.ModifySettings(cfgFile, "DVW_SMOOTHING", "1");
analysisSettings.LoadFrom(cfgFile);
System.IO.File.Delete(cfgFile);
analysis.ApplyAndWaitForCompletion();

C++

//Open a detector viewer
analysis = TheSystem->Analyses->New_Analysis(AnalysisIDM_DetectorViewer);
analysisSettings = analysis->GetSettings();
tmpnam_s(cfgFile, L_tmpnam_s);
analysisSettings->SaveTo(cfgFile);
analysisSettings->ModifySettings(cfgFile, "DVW_SHOW", "2");
analysisSettings->ModifySettings(cfgFile, "DVW_SMOOTHING", "1");
analysisSettings->LoadFrom(cfgFile);
remove(cfgFile);
analysis->ApplyAndWaitForCompletion();

Matlab

% Open a detector viewer
det_analysis = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.DetectorViewer);
det_analysisSettings = det_analysis.GetSettings();
det_cfgFile = System.String.Concat(SamplesFolder, '\API\Matlab\e17_DetectorViewer.cfg');
det_analysisSettings.SaveTo(det_cfgFile);
det_analysisSettings.ModifySettings(det_cfgFile, 'DVW_SHOW', '2');
det_analysisSettings.ModifySettings(det_cfgFile, 'DVW_SMOOTHING', '1');
det_analysisSettings.LoadFrom(det_cfgFile);
det_analysis.ApplyAndWaitForCompletion();

Python

# Open a detector viewer
det_analysis = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.DetectorViewer)
det_analysisSettings = det_analysis.GetSettings()
det_cfgFile = SamplesFolder + "\\API\\Python\\e17_DetectorViewer.cfg"
det_analysisSettings.SaveTo(det_cfgFile)
det_analysisSettings.ModifySettings(det_cfgFile, "DVW_SHOW", "2")
det_analysisSettings.ModifySettings(det_cfgFile, "DVW_SMOOTHING", "1")
det_analysisSettings.LoadFrom(det_cfgFile)
det_analysis.ApplyAndWaitForCompletion()
Parameters
settingsFileThe settings file.
Returns
Examples
CSharpStandalone_15_Seq_Optimization.cs, and CSharpStandalone_17_NSC_BulkScatter.cs.

◆ Verify()

IMessages ZOSAPI.Analysis.Settings.IAS_.Verify ( )

Connect with Ansys