We can get and set the folders in Project Preferences in OpticStudio using ZOS API.
- Save the Project Preferences Configuration(.CFG) file in Zemax LLC\Documents\Zemax\Configs or you can use default Project Prefrences configuration file OpticStudio
- Add the following code for connecting saved configuration file Python Code print('\n===PreferencesFile===\n')
cfgFile = r"ZemaxLLC\Documents\Zemax\Configs\Project_Prefferences_test.CFG"
print(os.path.exists(cfgFile))
if (cfgFile):
self.TheConnection.PreferencesFile = cfgFile
else:
print('Default OpticStudio.CFG preferences used\n') MATLAB Code: fprintf('\n===PreferencesFile===\n')
cfgFile = 'C:\Users\Documents\Zemax\Configs\Project_Prefferences_test.CFG';
if exist(cfgFile, 'file')
TheConnection.PreferencesFile = cfgFile;
fprintf('PreferencesFile: %s\n', char(TheConnection.PreferencesFile))
else
fprintf('Default OpticStudio.CFG preferences used\n');
end- Change the code in the BeginApplication method % Add your custom code here...
% Define variables for Project Preferences
Preference = TheApplication.Preferences;
PrefG = Preference.Folders;
Logic = {'False', 'True'};
% Read and print the initial settings
fprintf('\n===Check initial Settings===\n');
fprintf('ZplDirectory: %s\n', char(PrefG.ZplDirectory));
PrefG.ZplDirectory="C:\test\POP\POP\BEAMFILES";
disp(PrefG.ZplDirectory);Preference = TheApplication.Preferences
PrefG = Preference.Folders
Logic = {'False', 'True'}
# Read and print the initia settings
print('\n===Check initial Settings===\n')
print('ZplDirectory:', PrefG.ZplDirectory)
PrefG.ZplDirectory="C:\test\POP\POP\BEAMFILES"
print(PrefG.ZplDirectory)
- Change the code in the BeginApplication method % Add your custom code here...