Description This subroutine performs the Best Geometric Focus analysis in the specified coordinate system for all rays on the specified entity and reports the information to the output window. A variation of this command, BestFocus, allows the calculation to be returned into a data structure.
If needed, the ApplyFilterToRays() command can be used to apply a ray selection criteria filter to the ray buffer prior to calling the BestFocus command. The resulting calculation will operate only on those rays satisfying the ray selection filter criteria.
Syntax PrintBestFocus id, nCoordSys
Parameters id As Long Node number of the entity on which the rays must exist in order to be included in the Best Focus calculation.
nCoordSys As Long Node number of the coordinate system in which the Best Focus calculation will be performed and reported.
Example This example demonstrates how to use the BestFocus command to automatically reposition an entity. The PrintBestFocus command is used to relay information to the output window. The accompanying sample file "<install dir>\Resources\Samples\Tutorials & Examples\exampleBestFocus.frd" implements this example as an embedded script.
Sub Main
Dim op As T_OPERATION Dim bf As T_BESTFOCUS Dim sNode As Long, detNode As Long
ClearOutputWindow
'Find rear lens surface and detector node ID's sNode = FindFullName( "Geometry.OS 011-1110.Surface 2" ) detNode = FindFullName( "Geometry.DetectorPlane" )
'Trace the rays Print "Tracing initial configuration..." EnableTextPrinting False DeleteRays() TraceCreateDraw() EnableTextPrinting True
'Compute the best focus for rays on the surface "DetectorPlane" Element Primitive 'and give the results In the coordinate system of the rear lens surface Print "Computing best focus..." BestFocus GetChild(detNode), sNode, bf
'Print best focus information to the output window. Use rays on the child surface 'of the DetectorPlane Element Primitive node and print the results in the 'coordinate system of the rear lens surface. PrintBestFocus GetChild(detNode), sNode
'Use the results of the best focus calculation to move the detector plane. 'Operation 1 of the detector node is a Z-Shift. Print "" Print "Moving the detector plane..." GetOperation detNode, 1, op op.val1 = bf.z SetOperation detNode, 1, op
'Update the document Update
'Trace again for visual affect Print "Performing new trace..." EnableTextPrinting False TraceCreateDraw() EnableTextPrinting True
Print "All Done!"
End Sub
See Also
|