Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Omnistic/38e0a61b9dfb1b2fe5dd263093ec8a1e to your computer and use it in GitHub Desktop.
Save Omnistic/38e0a61b9dfb1b2fe5dd263093ec8a1e to your computer and use it in GitHub Desktop.
# Modules
import os
# Open the tolerancing tool
MyTol = TheSystem.Tools.OpenTolerancing()
# Set criterion to MF value
MyTol.Criterion = ZOSAPI.Tools.Tolerancing.Criterions.MeritFunction
# Perform a single run iteratively
# Set the number of runs to 1
MyTol.NumberOfRuns = 1
# Set the desired number of runs
CustomNumberOfRuns = 1
# Save Tolerance Data (by default in the same folder as the lens file)
MyTol.SaveTolDataFile = True
# Compose the full path to the Tolerance Data file
TolDataPath = os.path.dirname(os.path.abspath(TheSystem.SystemFile))
TolDataPath += '\\' + MyTol.TolDataFile
for ii in range(0, CustomNumberOfRuns):
# Run a single MC analysis
MyTol.RunAndWaitForCompletion()
# This is where I would read the ZTD file, but somehow I can't get the encoding right from OS
# Close the tolerancing tool
MyTol.Close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment