SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.

Home / forum / Lounges / Maya Basics & Newbie Lounge / Mel script?? How to write float numbers to a text file
Register FAQ Members List Calendar Mark Forums Read

New Thread
 
Thread Tools
Old 20-07-2008, 10:59 AM   #1
tootak
Registered User
 
Join Date: Jun 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
tootak is offline   Reply With Quote
Old 20-07-2008, 01:29 PM   #2
publicFunction
Senior Software Developer
 
publicFunction's Avatar
 
Join Date: Jan 2005
Location: Livingston, Scotland
Posts: 1,701
Thanks: 1
Thanked 23 Times in 23 Posts
Default

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.
publicFunction is offline   Reply With Quote
Old 20-07-2008, 02:02 PM   #3
gster123
Moderator
 
gster123's Avatar
 
Join Date: May 2005
Location: Manchester Uk
Posts: 6,300
Thanks: 1
Thanked 51 Times in 45 Posts
Default

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
gster123 is offline   Reply With Quote
New Thread

« Previous Thread | Next Thread »

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Open a Lightwave file in Maya 2011 radiant777 Maya Basics & Newbie Lounge 2 04-12-2010 02:45 AM
MEL headache!! happymat27 Mel Scripts & Programming 1 03-12-2010 03:41 PM

1 Month

$34

Month-to-month billing
$34/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
 
 

3 months

$87

Billing every 3 months
$29/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $5 per month or $15 in total compared to monthly billing with this package.

12 months

$288

Billing every 12 months
$24/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $10 per month or $120 in total compared to monthly billing with this package.

Your plan will automatically renew. You can cancel at any time via your PayPal account to avoid being charged again.

You can view the FAQ on our video plans here. You can contact us directly here. By clicking one of the buttons above, you agree to our Terms and Privacy Policy.