Zemax import: glass resolution#
load_zemax_file("design.zmx") resolves each glass the way OpticStudio
does: from the catalogs the file declares on its GCAT line, by exact name.
It never falls back to a fuzzy search across every catalog in the material
database, so an imported lens gets the glass the file asks for or a model of
it, never a different glass with a similar name.
Resolution order#
For each GLAS <name> <solve> <?> <nd> <vd> ... line:
Model glasses. A solve type of
1or the name___BLANKmarks an explicit model glass. It becomes anAbbeMaterialbuilt from nd/vd, without searching the catalogs.Declared catalogs, exact name. Every
GCATcatalog is searched for the exact name (case insensitive), withMaterial(name, catalog=..., match_policy="strict").Found in one catalog: that glass is used.
Found in several: the glass whose nd/vd best match the
GLASline is used, and the first catalog inGCATorder wins a tie or a line without nd/vd. A.zmxfile lists catalogs once for the whole file, so nd/vd are what tell, for example, Schott F2 from CDGM F2 on a given surface.
MIL-number names. A six-digit name such as
517642(or517.642) that no catalog contains is a model glass with nd = 1.517 and vd = 64.2, taken from the name.Not found. Any other glass becomes an
AbbeMaterialfrom the nd/vd on theGLASline, and anOptilandMaterialWarningnames the surface and glass. If the line has no nd/vd, import fails withValueError.
A glass modelled with vd = 0 is undispersed and becomes an IdealMaterial.
A GCAT catalog that is not in the material database (see
MaterialRegistry.instance().list_catalogs()) is skipped with a warning, so
its glasses are modelled from nd/vd. A file without GCAT models every
glass.
What changed#
Earlier versions fell back to Material(name), which searches every catalog
with substring and edit-distance matching. Some files now resolve to a
different material:
|
Before |
Now |
|---|---|---|
|
The BaF2 crystal ( |
Model glass from nd/vd, with a warning |
|
|
Model glass from nd/vd, with a warning |
|
|
Model glass from nd/vd, with a warning |
Glasses that a declared catalog contains under their exact name resolve as
before. Material(name) itself is unchanged; only the Zemax importer
resolves strictly.
Export#
save_zemax_file writes the catalog of each Material to GCAT and
records nd/vd on every GLAS line, so a saved file reloads to the same
glasses. A Material created without a reference exports the glass catalog
it resolved to.