Navigation: Scripting Reference Manual > Functions & Subroutines > SaveRayHistory

 

SaveRayHistory

 

Contact Us: fredsupport@photonengr.com

 

Description

This command saves the current ray history information to a text file, which consists of two header lines followed by rows of comma separated values.  Ray history data is simply a sequential listing of the X, Y, Z intersection positions (in global coordinates) for all rays.  Rows of data with four entries indicate the start of history information for a single ray, with the ray ID number being given as the first value in the four value line and the remaining three values corresponding to the ray's starting point.  Rows with three values are X, Y, Z intersection positions for the ray ID given on the previous four value row.  For example:

RAY HISTORY

Ray #,  X ,  Y ,  Z

0, -3.9, 4.44089e-016, -5

, -3.9, 4.44089e-016, 0

, -3.9, 5, -1.11022e-015

, -3.9, 5.19393, -1.14266e-015

, 0.0357567, 52.9391, -1.05982e-014

1, -3.12, -2.34, -5

, -3.12, -2.34, -2.34

, -3.12, 5, -2.34

, -3.12, 5.19393, -2.34

, 0.0286053, 52.9391, 0.021454

2, -3.12, -1.56, -5

, -3.12, -1.56, -1.56

, -3.12, 5, -1.56

, -3.12, 5.25544, -1.56

, 0.0103362, 52.9391, 0.00516808

 

The ray history output above shows data for rays numbered 0, 1 and 2.  Ray #1 has starting position X = -3.12, Y = -2.34, Z = -5 and final position X = 0.0286053, Y = 52.9391, Z = 0.021454.

 

 

Syntax

success = SaveRayHistory( fName )

 

 

Parameters

success (Boolean)

Returned boolean flag indicating whether ray history information was saved to the designated file (True) or failed to save (False).

 

fName As String

Specifies the full path name to the text file where ray information is being saved.

 

 

Example

The following example sets up an advanced raytrace to keep track of ray history information, checks to verify that the history exists and then writes the history data to a text file.

 

Sub Main

 

    Dim adv As T_ADVANCEDRAYTRACE

    InitAdvancedRaytrace adv

        adv.draw = True

        adv.rayHistory = True

        adv.rayPaths = True

 

    PathDeleteAll()

    DeleteRays()

 

    Dim numRays As Long

    numRays = AdvancedRaytrace( adv )

 

    Dim histFile As String, success As Boolean

    histFile = GetDocDir() & "\currentRayHistory.txt"

    If IsRayHistory() Then

        success = SaveRayHistory( histFile )

        If success Then

            Print "Ray history file saved."

        Else

            Print "Error saving ray history file."

        End If

    End If

 

End Sub

 

 

See Also

Basic Ray Data Commands

 

 

 

 

 

Copyright © Photon Engineering, LLC