Digital humans the art of the digital double
Ever wanted to know how digital doubles are created in the movie industry? This course will give you an insight into how it's done.
# 1 20-07-2008 , 10:59 AM
Registered User
Join Date: Jun 2008
Posts: 4

Mel script?? How to write float numbers to a text file

Hi All


I want to write some attributes of my objects to a text file using Mel . The values are stored in an array named W.
this is my the part of the code to do this :

$exampleFileName = ( "example.txt" );
$fileId=`fopen $exampleFileName "w"`;
fwrite $fileId $w[0];
fclose $fileId;


but it seems that Fwrite cannot handle float numbers? Do you have any idea?


Bests
Tootak

# 2 20-07-2008 , 01:29 PM
publicFunction's Avatar
Senior Software Developer
Join Date: Jan 2005
Location: Livingston, Scotland
Posts: 1,701
Try assigning the float number to a variable, and declare that variable as a floating point number before asking it to write and then output it to screen prior to writing it to the txt file to ensure that works...

float $w;
$w = `sum command`;

As an example...


Chris (formerly R@nSiD)
Twitter
When the power of love overcomes the love of power the world will truely know peace - Jimmy Hendrix
Winner SM VFX Challenge 1
3rd Place SM SteamPunk Challenge (May 2007)

Last edited by R@nSiD; 20-07-2008 at 01:37 PM.
# 3 20-07-2008 , 02:02 PM
gster123's Avatar
Moderator
Join Date: May 2005
Location: Manchester Uk
Posts: 6,300
In the MEL command command ref it recommends using fprint to write to a text file.

As Chris suggested make it print the array, also if you have an int in a float array, dont know why but maya thinks its a int eventhough you tell it it's a float, you need to have the .XX after the number eg 0.0 to make a float.


"No pressure, no diamonds" Thomas Carlyle
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads