Hi John,
Got it working. Thanks for pointing me in the right direction. Had to do a bit of learning along the way. I used the CSV and JSON classes. My main script read the original data, processed it into 3d points, and produced an array of lines. After I got all the lines working, I added a block to write the array to file. The second script reads this file, draws a single line, removes it from the array, and writes the array back to file. Here's the pseudo code for the second script:
access the entities container
|
|
load required classes
[pre:2k0pic0s]require "CSV"
require "JSON"[/pre:2k0pic0s]
take a working copy of the file
check each time through
unless File.exist? <filename>
[pre:2k0pic0s]#take a copy[/pre:2k0pic0s]
end
load the lines into an array
[pre:2k0pic0s]line_arr = CSV.read(<filename>)[/pre:2k0pic0s]
convert points from string to array of floats
this caused the most grief until I got it right
[pre:2k0pic0s]line_arr.map! {|line| line.map {|pt| JSON.parse(pt)}}[/pre:2k0pic0s]
#draw a line
[pre:2k0pic0s]ent.add_edges line_arr[0][/pre:2k0pic0s]
#dump the line
[pre:2k0pic0s]line_arr.shift[/pre:2k0pic0s]
#replace the array in the file after checking for last line
if <last line>
[pre:2k0pic0s]File.delete(<filename>)[/pre:2k0pic0s]
else
[pre:2k0pic0s]CSV.open(<filename>,"wb") do |csv|
[pre]line_arr.each{|x| csv<< x}[/pre:2k0pic0s]
end[/pre]
end
#use the up arrow to execute as many times as lines