How to use Matlab or Python to use ZTD tolerance analysis data?

  • 11 November 2021
  • 4 replies

I know I can manually load the ZTD file using Tolerancing data viewer and copy the data to excel.  I would like to automate the procedure using Matlab or Python since I have more than 50 ZTD files. Thank you very much.


Best answer by David.Nguyen 12 November 2021, 11:14

View original

4 replies

Userlevel 5
Badge +1

Hi Yao,


It is tricky cause I don’t think the Tolerance Data Viewer is implemented in the ZOS-API. However, the *.ZTD file can be opened with a text editor like Notepad++.

Although there are some encoding issues, and perhaps binary content, most of the file seems fine. You could try to directly read the *.ZTD file with MATLAB/Python, and see what it gives you.

Let me know if that works for you.

Take care,



Hi David,

Thanks for the suggestion. I  checked the Monte Carlo section of the ZTD file, unfortunately, this section is encrypted.:joy:


Userlevel 4
Badge +1

Hi Yao and David,

I just wanted to step in here and make a quick comment that the Tolerancing Data Viewer is implemented in the ZOS-API :slight_smile: You’ll need to use the IToleranceDataViewer interface:

Properties of ToleranceDataViewer include Monte Carlo data, Sensitivity data, etc.:

So, I ran a tolerance on one of our sample files to get the following Monte Carlo data:


With the following code in MATLAB:
TheSystem = TheApplication.PrimarySystem;

tolDataView = TheSystem.Tools.OpenToleranceDataViewer();

tolDataView.FileName = "C:\ … \Yao_CookeTripletTest.ZTD";


MCData = tolDataView.MonteCarloData;

MCDataValues = MCData.Values.Data.double;

We can get the values for each column in the Monte Carlo data:


The column headers are stored as the Monte Carlo metadata, which you can pull per-column with GetMetadata():


Let us know if we can be of any more help -- thanks!

Userlevel 5
Badge +1

Thank you for correcting me @Angel Morales!