The NSC Surface Sag (available in Ansys Zemax OpticStudio 2023 R1 and OpticStudio 23.1) is fully implemented in ZOS-API. It means that you can open that analysis, define the settings and get the results. It makes it easy to convert an object face into a Grid Sag Surface.
Here is an example of a Matlab code:
TheSystem=TheApplication.PrimarySystem;
MyNSCSag = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.NSCSurfaceSag)
MyNSCSag.HasAnalysisSpecificSettings
returns True
The settings are:
MyNSCSag.ApplyAndWaitForCompletion
MyNSCSag_results = MyNSCSag.GetResults
returns a DataGrid containing the sag points
Sag = MyNSCSag_results.GetDataGrid(0).Values.double;