Writing Data to file
To open a text file and write data into it line by line:
Dim success As Boolean, i As Long, ray As T_RAY, lineToPrint As String Dim surf As Long surf = FindFullName( "Geometry.Plane.Surface" ) 'open file for writing Dim filename As String filename = GetDocDir() & "\rayfile.txt" Open filename For Output As #1 'now loop over rays success = GetFirstRay(i, ray) While success If ray.entity = surf Then 'translate global positional data to local TransformPosition -1, surf, ray.x, ray.y, ray.z 'translate global directional data to local TransformDirection -1, surf, ray.a, ray.b, ray.c Print #1, ray.x & Chr(9) & ray.y & Chr(9) & ray.z & Chr(9) & ray.a & Chr(9) & ray.c & Chr(9) & ray.power & Chr(9) & ray.wavelength End If success = GetNextRay(i, ray) Wend Close #1
The script above loops over all rays in the buffer. The local position and direction data for each ray located at the designated surface are written to the file.