Navigation: Scripting Reference Manual > Functions & Subroutines > SaveRaytraceRayPathsToFile

 

SaveRaytraceRayPathsToFile

 

Contact Us: fredsupport@photonengr.com

 

Description

This function saves the current raytrace path data to a binary file and returns a count of the number of paths that were written.  The binary file can be read back into FRED using the ReadRaytraceRayPathsFromFile function.  A Python script utility ( <install dir>\Resources\Samples\Scripts\Python\ListFRPFileContents.py ) is also provided that can process and report the raypath file data independently.

 

Note: Modifications to the "filtered" values associated with each raytrace path are not saved into the *.frp file.

 

 

Syntax

pCount = SaveRaytraceRayPathsToFile( fName )

 

 

Parameters

pCount (Long)

The number of paths that were written to file.

 

fName As String

The full path name of the binary raypath file that will be written. The raypath file should have extension FRP.

 

 

Example

The following script demonstrates how to raytrace with paths in a loop, saving raypath files on each iteration and then re-combining them in a merge operation.

Sub Main()

 

    'Base directory where raypath files will be saved

    Dim baseDir As String

    baseDir = "C:\temp\"

 

    'Delete any existing raytrace paths

    SetUserDefinedRayPathMode( False )

    PathDeleteAll()

 

    'Number of raytrace loops we would like to take

    Dim loopCount As Long

    loopCount = 3

 

    'Advanced raytrace initialization

    Dim tAdv As T_ADVANCEDRAYTRACE

    InitAdvancedRaytrace( tAdv )

        tAdv.draw     = False

        tAdv.rayPaths = True

 

    'Raytrace loop with path file saving

    Dim curLoop As Long, pCount As Long

    Dim curPathFile As String

    pCount = 0

    For curLoop = 1 To loopCount

        'Trace and save current paths

        AdvancedRaytrace( tAdv )

        curPathFile = "rayPaths_" & CStr(curLoop)

        pCount      = pCount + SaveRaytraceRayPathsToFile( baseDir & curPathFile )

 

        'Delete current paths

        PathDeleteAll()

    Next

    Print pCount & " paths saved to file(s)"

 

    'Go back and load all paths from files

    pCount = 0

    For curLoop = 1 To loopCount

 

        curPathFile = "rayPaths_" & CStr(curLoop)

        pCount      = pCount + ReadRaytraceRayPathsFromFile( baseDir & curPathFile, True)

 

    Next

    Print pCount & " paths read from file(s)"

 

End Sub

 

 

See Also

ReadRaytraceRayPathsFromFile

Path Scripting Commands

 

 

 

 

 

Copyright © Photon Engineering, LLC