Maya 2020 fundamentals - modelling the real world
Get halfway through a model and find it's an unworkable mess? Can't add edge loops where you need them? Can't subdivide a mesh properly? If any of this sounds familiar check this course out.
# 1 29-03-2006 , 02:57 AM
mayakid14's Avatar
Registered User
Join Date: Nov 2004
Location: Florida
Posts: 105

String to Int

Does anyone know if there is a way to convert a string to an int or a float.
Example:

string $mystring = "15";
int $myint = ($mystring - 1);
print $myint;

Maya doesn't execute this script because $mystring doesn't really have a int value. In BASIC I think this concept would be written as:
Dim mystring As string = "15"
Dim myint As integer = (val(mystring) - 1)
MsgBox(myint)
The VAL function works in BASIC but it won't work in MEL. Of course it doesn't seem like MEL hasa VAL function but is there an alternative?


I hope you didn't waste your time reading this line.
# 2 29-03-2006 , 09:23 AM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
you're talking about casting.

you can cast a string like this:

string $strVal = "150000";
int $intVal = (int)$strVal;
float $floatVal = (float)$strVal;


and you can go the other way too:

int $intVal = 1545;
string $strVal = (string)$intVal;

user added image
A


Technical Director - Framestore

Currently working on: Your Highness

IMDB
# 3 29-03-2006 , 02:35 PM
mayakid14's Avatar
Registered User
Join Date: Nov 2004
Location: Florida
Posts: 105
Whoa thanks a bunch. Never thought there would be a way for this. Couldn't find anything in the reference commands or anything.
user added image You're Awsomeuser added image


I hope you didn't waste your time reading this line.
# 4 29-03-2006 , 03:12 PM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
no problem. Casting is common in many programming languages.

user added image
A


Technical Director - Framestore

Currently working on: Your Highness

IMDB
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