Skip to main content
Solved

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

  • November 11, 2021
  • 6 replies
  • 804 views

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

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,

 

David

View original
Did this topic help you find an answer to your question?

6 replies

David.Nguyen
Luminary
Forum|alt.badge.img+2
  • Luminary
  • 1097 replies
  • Answer
  • November 12, 2021

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,

 

David


  • Author
  • Monochrome
  • 3 replies
  • November 15, 2021

Hi David,

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

 


Angel Morales
En-Lightened
Forum|alt.badge.img+1
  • En-Lightened
  • 203 replies
  • November 17, 2021

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";

tolDataView.RunAndWaitForCompletion();

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!


David.Nguyen
Luminary
Forum|alt.badge.img+2
  • Luminary
  • 1097 replies
  • November 18, 2021

Thank you for correcting me @Angel Morales!


alexander_dumont

Hi all 

 

Does this situation still work? I am tying to do the same thing using C# ZOS-API, but in my case, when I try to do 

 var tolDataView = TheSystem.Tools.OpenToleranceDataViewer();
I get a system null reference exception which means I can't access my MC data. 


David.Nguyen
Luminary
Forum|alt.badge.img+2

Hi Alexander,

 

This piece of code works for me in Python:

TolDataViewer = TheSystem.Tools.OpenToleranceDataViewer()
TolDataViewer.RunAndWaitForCompletion()
print(TolDataViewer.SensitivityData.NumberOfResultOperands)
TolDataViewer.Close()

And it returns the correct number of operands. Therefore, I have no reason to suspect this shouldn’t work in C#. Are you able to share more of your code with us?

Take care,

 

David


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings