PDA

View Full Version : Stuck on a max 6 script bug


WightWorks
29-10-2004, 09:10 AM
I created this utility script for max 6 to import specially formatted text files that control the motion of the objects in my scene (I'm using this to visualize simulations). Although the script itself seems to work well, there is one bug that I haven't been able to find. After I open max, I open my animation file, then open and evaluate the script below, click "Process Data File", and select my file. It always returns with "Unknown property: pos in undefined" and "CurrentObject.pos = [x,y,z];" is highlighted. I then evaluate the script a second time, click process data, select my file and everything works perfectly. I only need to do this each time I start max, so I'm assuming that there is a global variable I'm setting somewhere that I'm not initializing or something like that? Any suggestions would be appreciated. Thanks!

Derek Wight.


utility IllacImporter2D "Illac Importer 2D"
(

button ButProcess "Process Data File"

on ButProcess pressed do
(
clearListener()

FileName = getOpenFileName()

if FileName != undefined then
(
print FileName
fid = openFile FileName

Frames = readValue fid
print Frames

Objects = readValue fid
print Objects

undo "Load Animation Data" on
(
for i = 1 to Objects do
(

ObjectName = readLine fid
ObjectName = "CurrentObject = $" + ObjectName
print ObjectName

execute ObjectName

animate on
(
rr_last = 0;

for j = 1 to Frames do
(

x = readValue fid
z = readValue fid
y = readValue fid

y = -y

rr = readValue fid
rot = angleaxis (rr-rr_last) [1,0,0]
rr_last = rr;

vis = readValue fid

at time (j-1)
(

CurrentObject.pos = [x,y,z];
rotate CurrentObject rot;
)
) -- end for
) -- end animate on
) -- end for
) -- end undo

close fid

) else (

print "User canceled"
)
)
)