Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Maya Basics & Newbie Lounge (https://simplymaya.com/forum/forumdisplay.php?f=31)
-   -   Mel script?? How to write float numbers to a text file (https://simplymaya.com/forum/showthread.php?t=30465)

tootak 20-07-2008 10:59 AM

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

publicFunction 20-07-2008 01:29 PM

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...

gster123 20-07-2008 02:02 PM

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.


All times are GMT. The time now is 09:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018