Lens Element Scripting
The example file below contains an embedded script called "Modify Lens Element" that demonstrates various scripting commands that manipulate Lens elements and surfaces. The example script demonstrates how to:
- Set lens construction parameters (surface shapes, center thickness, etc.)
- Set lens aperture parameters
- Set lens surface properties (coatings, scatter models, etc.)
- Shift a lens element
- Set visualization attributes of a lens element
Dim lNode As Long lNode = FindFullName( "Geometry.Lens 1" ) 'Basic lens construction properties Dim tEnt As T_ENTITY Dim tLens As T_LENS GetLens( lNode, tEnt, tLens ) tLens.paramType = "Radii" tLens.param1 = 25.0 'Front surface radius tLens.param2 = -45.0 'Rear surface radius tLens.thickness = 5.5 SetLens( lNode, tEnt, tLens ) 'Edge diameter, front and rear surface clear apertures Dim tEdge As T_EDGEBEVELS 'Outer edge tEdge.outerX = 12.7 tEdge.outerY = 12.7 'Front surface CA tEdge.frontX = 11.25 tEdge.frontY = 11.25 'Rear surface CA tEdge.backX = 11.7 tEdge.backY = 11.7 SetElementEdgeBevels( lNode, tEdge ) 'Update model so that bevels get added to geometry Update 'Set surface properties 'Lens element surfaces have the following names 'Surface 1 << Front Surface 'Surface 2 << Rear Surface 'Bevel 1 << Front bevel 'Bevel 2 << Rear bevel 'Edge << Outer edge Dim arCoat As Long, uCoat As Long Dim lensCtrl As Long Dim hsScatter As Long, laScatter As Long Dim surf As Long arCoat = FindCoating( "AR" ) uCoat = FindCoating( "Uncoated" ) lensCtrl = FindRaytraceCtrl( "Refractive Optics" ) hsScatter = FindScatter( "Harvey Shack" ) laScatter = FindScatter( "Lambertian 30" ) 'Front surface surf = FindFullName( GetFullName( lNode ) & ".Surface 1" ) SetSurfCoating( surf, arCoat ) SetSurfRaytraceCtrl( surf, lensCtrl ) RemoveAllScatterProp( surf ) AddSurfScatter( surf, hsScatter ) 'Rear surface surf = FindFullName( GetFullName( lNode ) & ".Surface 2" ) SetSurfCoating( surf, arCoat ) SetSurfRaytraceCtrl( surf, lensCtrl ) RemoveAllScatterProp( surf ) AddSurfScatter( surf, hsScatter ) 'Front bevel surf = FindFullName( GetFullName( lNode ) & ".Bevel 1" ) SetSurfCoating( surf, uCoat ) SetSurfRaytraceCtrl( surf, lensCtrl ) RemoveAllScatterProp( surf ) AddSurfScatter( surf, laScatter ) 'Rear bevel surf = FindFullName( GetFullName( lNode ) & ".Bevel 2" ) SetSurfCoating( surf, uCoat ) SetSurfRaytraceCtrl( surf, lensCtrl ) RemoveAllScatterProp( surf ) AddSurfScatter( surf, laScatter ) 'Outer edge surf = FindFullName( GetFullName( lNode ) & ".Edge" ) SetSurfCoating( surf, uCoat ) SetSurfRaytraceCtrl( surf, lensCtrl ) RemoveAllScatterProp( surf ) AddSurfScatter( surf, laScatter ) 'Move lens into position 'Need to specify a coordinate system for the operation, will assume global (2) Dim tOp As T_OPERATION tOp.parent = 2 tOp.Type = "ShiftZ" tOp.val1 = 25.0 AddOperation( lNode, tOp )
Example file: LensElementScripting.frd