Solved

ZPL Question with SPRO

  • 10 August 2022
  • 2 replies
  • 88 views

I’m converting ZPL macros to ZOS API using C#

I’ve having a hard time finding the corresponding API for the macro SPRO(surf, code) with Code = 18

From the macro documentation, code 18 will return the Glass Number (an integer?) for a Surface.

Does anyone know the corresponding   ZOS API code?

 

I currently use OpticalSystem.LDE.GetGlass() to get the glass name. How about accessing the glass number?

 

icon

Best answer by MichaelH 10 August 2022, 21:12

View original

2 replies

Userlevel 6
Badge +2

Hi Brian,

There is no “glass number” in the API.  In the ZPL, this is simply the order of the glass as they appear in the AGF/BGF glass catalog.  If you have multiple catalogs loaded, then the 2nd catalog starts as the n+1 glass number.  C# code to achieve this would be as follows (note that since this isn’t a built-in function and not documented in the Help Files, this is subject to change without warning):

private static int GlassNumber(IOpticalSystem opticalSystem, int surf)
{
int result = -1;
int gnum = 0;

var tool = opticalSystem.Tools.OpenMaterialsCatalog();
string[] catalogs = opticalSystem.SystemData.MaterialCatalogs.GetCatalogsInUse();
for (int i = 0; i < catalogs.Length; i++)
{
tool.SelectedCatalog = catalogs[i];
string[] glasses = tool.GetAllMaterials();

for (int j = 0; j < glasses.Length; j++)
{
gnum++;
if (glasses[j].ToUpper() == opticalSystem.LDE.GetSurfaceAt(surf).Material.ToUpper())
{
tool.Close();
return gnum;
}

}
}

tool.Close();
return result;
}

 

Hi Michael,

Thanks for the quick reply.

I was thinking that it was associated with the catalogs but I didn’t think of going into the Tools part of the
code.  I’m giving this a try now.

Thanks again.
B.
 

 

Reply