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?
Best answer by MichaelH
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):
privatestaticintGlassNumber(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;
}
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):
privatestaticintGlassNumber(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;
}
We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.