Solved

How to change 3D layout properties via ZOSAPI

  • 31 March 2023
  • 4 replies
  • 140 views

Hi,

I am trying to change 3D layout properties via MATLAB ZOSAPI. I’ve checked help and googled and didn’t find the answer.  For example, how could I change “Number Of Rays”, “Ray Pattern”, Rotation and all other settings via ZOSAPI. Also, is it possible to change line thickness via ZOSAPI??    

 

icon

Best answer by David.Nguyen 31 March 2023, 17:57

View original

4 replies

Userlevel 7
Badge +2

Hi Shih-Heng,

 

This is not straightforward because the 3D Layout is not fully implemented in the ZOS-API. To make things worst, the 3D Layout is also not implemented in ZPL (although the number of rays is available for 2D Layout in ZPL).

Let me share what you could try with an example. Suppose you want to switch between different values of Number Of Rays, say 10, and 100 for example. You can open the settings of your 3D Layout, set the Number Of Rays to 10, and press the Save button. The Save button creates a file that has the same name as your lens file but with the *.CFG extension. You can rename this file, for example, 3D_Layout_10_rays.CFG, and then do the same with 100 (the file will be called 3D_Layout_100_rays.CFG). Then, in the ZOS-API, you can get the settings of your 3D Layout and use the LoadFrom method to load the settings of either file:

# Create a new 3D Layout
Layout3D = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.Draw3D)

# Load specific settings from a *.CFG file
Layout3D.GetSettings().LoadFrom('<full_path>\3D_Layout_10_rays.CFG')

# Apply settings and run analysis
Layout3D.ApplyAndWaitForCompletion()

This is in Python, but I’m fairly sure you can make it work with MATLAB. The main issue is that you have to create those *.CFG files manually…

For the Line Thickness, since its not in the *.CFG file (as far as I’ve tested), I don’t think it is possible.

Hope this helps, and take care,

 

David

Thanks David. 

It really helps a lot. I use both Python and MATLAB with ZOSAPI, and I guess the ZOSAPI commands for both Python and MATLAB are almost identical, just with minor differences.     

 

 

Thanks David. 

It really helps a lot. I use both Python and MATLAB with ZOSAPI, and I guess the ZOSAPI commands for both Python and MATLAB are almost identical, just with minor differences.     

 

I accidentally selected my “Thank you” reply as best answer. the answer from David Nguyen is indeed the best answer. Can anyone tell me how to fix this. 

Thanks 

Userlevel 6
Badge +2

Hi @Shih-Heng.Lin!

The Community moderators can update the “Best Answer” on a given post. If you need help with this in the future, tag me, Yuan Chen, Yihua Hsiao or Sandrine Auriol using the “@” symbol!

I have updated the “Best Answer” to David’s post. Cheers :).

Reply