Skip to main content
Solved

Wolfram Mathematica NSCShadedModel

  • April 21, 2022
  • 4 replies
  • 99 views

Dear comunity.

 

What is the syntax to open a shaded model from Wolfram Mathematica?

 

analysis =  TheSystem@Analyses@NewUAnalysis["ZOSAPI.Analysis.AnalysisIDM.NSCShadedModel"]

 

returns 

 

NET::methodargs: Improper arguments supplied for method named NewUAnalysis.

 

Thanx and BR,

Jozef

Best answer by Allie

Hi @Jozef.Pulko 

For using a command with an enumerated input within Mathematica, you must first load the enum via the LoadNETType command. For example, the enum for the NSC Shaded Model is “ZOSAPI.Analysis.AnalysisIDM”, so I will enter that as shown below:

 

LoadNETType["ZOSAPI.Analysis.AnalysisIDM"];

 

Once loaded, you can choose the enumerator you wish to use by using the ` operator and the final section of the enum value. (That operator is the key to the left of the “1” and above “Tab” on a typical keyboard.) For example, to select NSC Shaded Model with the ZOSAPI.Analysis.AnalysisIDM enum loaded, we would use this command:

 

theSystem@Analyses@NewUAnalysis[AnalysisIDM`NSCShadedModel];

 

As long as the enum is loaded somewhere in the document (and evaluated), you can call any enumerator value from its list using the ` operator. This is exemplified in Sample 3 from within the C:\...\Zemax\ZOS-API Sample Code\Mathematica folder, where we insert optimization operands into the Merit Function Editor using the MeritOperandType enum. 

Let me know if you have any other questions about this!

4 replies

MichaelH
Ansys Staff
Forum|alt.badge.img+2
  • Ansys Staff
  • 402 replies
  • April 21, 2022

Hi Jozef,

The NSC Shaded model is only available if TheSystem is currently a non-sequential system.  By default, new systems are sequential mode.  Can you confirm your system is non-sequential (I don’t use Mathematica so I’m not sure if the code below has the correct @ & double quotes):

TheSystem@Mode == "ZOSAPI.SystemType.NonSequential"

If your system is already non-sequential, then it is something with the ZOSAPI enum you are calling.


  • Author
  • Infrared
  • 5 replies
  • April 25, 2022

Hi Michael,

 

yes my system is non-sequential. For example TheSystem@NCE@InsertNewObjectAt[2] works.

 

TheSystem@Mode returns 

BR,

Jozef


Allie
Zemax Staff
Forum|alt.badge.img+2
  • Zemax Staff
  • 346 replies
  • Answer
  • April 25, 2022

Hi @Jozef.Pulko 

For using a command with an enumerated input within Mathematica, you must first load the enum via the LoadNETType command. For example, the enum for the NSC Shaded Model is “ZOSAPI.Analysis.AnalysisIDM”, so I will enter that as shown below:

 

LoadNETType["ZOSAPI.Analysis.AnalysisIDM"];

 

Once loaded, you can choose the enumerator you wish to use by using the ` operator and the final section of the enum value. (That operator is the key to the left of the “1” and above “Tab” on a typical keyboard.) For example, to select NSC Shaded Model with the ZOSAPI.Analysis.AnalysisIDM enum loaded, we would use this command:

 

theSystem@Analyses@NewUAnalysis[AnalysisIDM`NSCShadedModel];

 

As long as the enum is loaded somewhere in the document (and evaluated), you can call any enumerator value from its list using the ` operator. This is exemplified in Sample 3 from within the C:\...\Zemax\ZOS-API Sample Code\Mathematica folder, where we insert optimization operands into the Merit Function Editor using the MeritOperandType enum. 

Let me know if you have any other questions about this!


  • Author
  • Infrared
  • 5 replies
  • April 26, 2022

This works. Thank you!