[Closed] Animating with text files
Hi,
I would like to animate (transform) an object by reading in the frames and the coordinates for the keys from an external text file. The text file is a table containing the object name the frame number and the x,y,z transform parameters (PRS)
Can this be done and could someone help me with this or guide me in the right direction plse?
Thanks a zillion.
SiSco
hi,
what you are asking is possible – i have done it by reading in arrays from a text file –
all i did was create the arrays and then include the file with the “filein” function
mark
Hi Mark,
Thanks for your reply Mark, I’m only aquainted with the very basics of scripting, but very very bitten by the bug to be able to controll objects and animation by text files. Any chance you can explain a litle more on how to start such a script, or how to include the file with the “filein” function
I noticed you made some morph scripts Mark, perhaps I can ask you another question which was on my mind. Is it possible to read in morph targets and percentages from a text file for a specific object and have keyframes created in the morph controller at specified frames? If it is possible I am really realy interested in finding out more and learning how to do this, any help links , samples or tutorials on this are very much appreciated. Thank you very much for your time.
SiSco
hi,
Any chance you can explain a litle more on how to start such a script, or how to include the file with the “filein” function
sorry i am really busy at the moment and i do not have time to go into it further – i can give you some advice though – jump straight in and write the script yourself – read and use the maxscript referenece – it is a little hard to find stuff soemtimes but it is very good.
Is it possible to read in morph targets and percentages from a text file for a specific object and have keyframes created in the morph controller at specified frames?
this is possible and once you start to dabble in scripting it will be very easy
good luck
mark
Hi Mark,
Thanks for your answer, at least i know I’m not asking impossible things from maxscript.
I started digging in the reference right away, but I still silently hope for a little help from someone since I’m afraid it will take too long to find out everything myself by reading the reference. Not having much programming knowledge doesn’t make it easier or more encouraging either. Any links or tutorials for a good start on this type of scripting perhaps Mark, or anyone?
thanks a lot
sisco
I recently made this just as a sort of “proof of concept”
rollout FileTest "FileTest" width:192 height:48
(
button PrintData "PrintData"
on PrintData pressed do
(
ParsedFile = openFile "c:\ est.txt"
TestArray = #()
for i = 1 to selection.count do
(
Data = readDelimitedString ParsedFile ","
append TestArray Data
)
print TestArray
for i = 1 to selection.count do
(
selection[i].height = TestArray[i] as float
)
)
)
CreateDialog FileTest width:192-- creating the dialog
Where I have a comma seperated text file located in my root c:\ drive called text. In this instance i used it to adjust a box height, but basicly you could use the text file to animate stuff or whatever. Probably the number of objects selected in this example can not be larger than the number of values in the comma seperated txt file. If that is the case, an error will probably occur. But still I think this is the basic concept of what you need. Hope this was usefull, and I am in no way a programmer, so please be overbearing:)
Great,
Thanks a lot for the example Mdahl. Indeed a great start, and also an encouragement… seeing you’re not a programmmer either. Do you know of any good books on maxscript, would you recomend any, or how did you go about learning it? (my last real last programming experience was in “basic”… 🙁 )
thx
sisco
There are two decent options as regards learning – john wainwright (the guy who made maxscript) has a cd called maxscript 101 that covers a lot of it and cg academy do a set of dvds written by Lazslo sebo and Borislav petrov that cover a really solid foundation of things – Neither of them will specifically cover filein stuff but they will cover arrays, reading + writing keyframes and using loops which are pretty much the basis for what you want to do. Writing text files out isn’t difficulty at all so the maxscript help should be fine for that. What might be the problem is not knowing where to start making this tool so try and break it down into simple logical steps. Say for example:
- Pick an object in your scene to apply the animation to [assigining selections / pickbutton]
- Read a text file [file in stuff]
- Take a look at the arrays writen in the text file and see are specific names there (maybe have an array called x_anim, y_anim, z_anim) [variable names, arrays]
- For each of the arrays, do a loop through the values of the array from 1 up to the total number of entries in the array and set a keyframe for the object with the arrays value [for loops,setting keyframes]
So the parts in square brackets are what you need to look up in the maxscript reference – It might be an idea not to try every thing at once since it might be a bit overwhelming – break it down into each individual section to make sure you can get each of the parts of the code to work on their own and then gradually combine them into the full thing when you’re confident about each part working.
Best of luck!
I do not know of any books that are better than the built in help file. But there are a few trining dvds out there that are quite good at getting the basics down
The way I learned what I know was to not search scriptspot when I had an idea for a script, and just go ahead and fix the problem my self. Now that I have the basics down, scriptspot is a superb resource, not only for scripts that you need, but also as a learning tool. Check out peoples scripts to see how they do it… But before you can do that you need the basics and that is the biggest hurdle. Also the maxscript 101 dvd is cool… And also kiss, dude, keep it simple at least at the beginning. I.e, make a script that adjusts the height of several boxes in a scene, then build on that…
Slowly it will all make sence:) Enjoy…
Hi,
Just as a test, I wrote this script. Check it out to see if it’ll work for you SiSco!
Installation instruction in the script; 123.txt is a sample position/keyframe table.
My script however, allows you to choose an object to apply the keyframes to, so the data in the text file comes in the format
[x,y,z]|keyframe
where [x,y,z] is the position,
| is my delimiter (pipe)
and keyframe is a numerical value for the keyframe.
HTHs!
GW