Maya Training

Introduction to Hard Surface Modeling

Maya Training

Interiors and Furniture Vol 1 & 2 - Modeling & Cloth

Maya Training

Shading, Lighting and Rendering the Bedroom in MR

Maya Training

Robot volume one - Modeling with animation in mind

Maya Training

Spach-Alspaugh House the complete courseware

Maya Training

Burt The Cartoon Dinosaur Vol 01 - Modeling

New Maya Training

Batman by Jason Edwards
You are here > Home > SimplyMaya Community Forums

Welcome to Simply Maya

Please Sign in or Sign up for an account

Member Login

Lost your password?

Not a member yet? Sign Up!

Old 20-07-2008, 10:59 AM   #1
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?

tootak is offline   Reply With Quote
Old 20-07-2008, 01:29 PM   #2
Senior Software Developer
publicFunction's Avatar
Join Date: Jan 2005
Location: Livingston, Scotland
Posts: 1,701
Thanks: 1
Thanked 23 Times in 23 Posts

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)
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's Avatar
Join Date: May 2005
Location: Manchester Uk
Posts: 6,300
Thanks: 1
Thanked 51 Times in 45 Posts

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

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

Thread Tools

A little bit about who we are
Links you might find useful
Catch up with SimplyMaya
SimplyMaya specialises in Maya tutorials. We offer over 1,000 individual Maya training videos, ranging from basic Maya tutorials through to intermediate Maya tutorials. Our tutorials are created by instructors with industry experience and are designed to get you up and running in Maya quickly without making it seem like hard work.

Copyright © 1999-2015 SimplyMaya - vBulletin® Copyright © 2000-2015, Jelsoft Enterprises Ltd.