[Closed] formating .txt file data
i am writing a script to export all the camera information to .TXT file, i am able to save the .txt file with whatever data i want from my scene camera but i am not able to format that contant
ex: i am getting .txt data like “x=20.45634” but i want only 3 digit to be saved (like x=20.3)
can anyone explain me how to format this thing…
my .txt file data:
x=10.34567 y=43.557432 z=45.687845
i want the .txt data to be:
x=10.3 y=43.5 z=45.6
mt script is something like this
“format “% % % ” master.pos.x master.pos.y masterpos.z to filehandler “
thanking u
-mani.
:buttrock:
Just write a little truncate function like:
fn round num = return ((int((num * 10)))/10.0)
and then do
format “% % % ” trunc(master.pos.x) trunc(master.pos.y) trunc(master.pos.z) to:filehandler
If you wanted to get fancier, you could write a rounding function instead of just truncating the values, but if this is all the precision you really need then I don’t suppose that would be necessary.
RH
Shouldn’t it be
format “% % % ” round(master.pos.x) round(master.pos.y) round(master.pos.z) to:filehandler
not trunc? I think your naming got messed up somehow.
Well, that’s what you get when you copy/paste code. After I decided to do it as a simple truncation rather than a complex rounding, I changed the function name to trunc() and then forgot to paste over that part:rolleyes:
RH