importing txt xyz as a trajectory for animation.
I have used this great script from Bobo
that imports xyz data and creates an animation trajectory.
I have a data file (see attached) with multiple data sets (different objects) that are seperated by a line break.
How would i edit this script to read in the multiple data sets and create seperate trajectories?
(--start a local scope. You can add a MacroScript definition above to make it a button
--pick the file:
local theFilename = getOpenFileName types:"Comma Separated Values (*.CSV)|*.CSV|All Files (*.*)|*.*”
if theFilename != undefined do ( --if a valid filename picked,
local theFile = openFile theFilename --open the file
local theDummy = Point showtrajectory:true --create a helper with trajectory on
while not eof theFile do ( --loop until the end of tile
theTime = floor ((readValue theFile)*30 + 0.5) --read time and round to closest frame
with animate on --enable autokey animation context
at time theTime --set the current time for the following expression
theDummy.pos = Point3 (readValue theFile) (readValue theFile) (readValue theFile)
)--and read the position from the file for each time step
close theFile --close the file when done
Note that your file was saved at 30 FPS frame rate, so the time samples have to be multiplied by 30 to give you frames. If you want to resample to a different frame rate or remove the quantization of values to full frames, you can change the line to
theTime = (readValue theFile)*FrameRate
This will import the 30 samples on sub-frames if the FrameRate is, say, 24 or 25, and at 30 you might get some frame values like 3.999 instead of 4.0, showing as narrow keys in the timeline. Dividing 1.0 by 30.0 is not fun