Beginner having troubles
Hi guys
string axis = "x";
MPoint point;
if (point.axis == 0)
{
}
Simplified version of some maya api code,but you get the idea :)
axis is the flag for the command and can be x,y or z.In this case it is set to x for demonstational purposes.
This is the problem point.axis
I can't do it like that,and i want if x is chosen to compare only x value of the point with some else.So how to do it?
thank you
Quote:Original post by TheMan22What's wrong with if (point.axis.x == 0)? What is "MPoint::axis"?
Hi guys
string axis = "x";
MPoint point;
if (point.axis == 0)
{
}
Simplified version of some maya api code,but you get the idea :)
axis is the flag for the command and can be x,y or z.In this case it is set to x for demonstational purposes.
This is the problem point.axis
I can't do it like that,and i want if x is chosen to compare only x value of the point with some else.So how to do it?
thank you
What does the local variable, "axis" have to do with anything?
MPoint does not have axis method.
axis is a variable and can get values x,y,or z.
MPoint has methods MPoint::x,MPoint::y and MPoint::z
So axis tells which one of those should be used,you understand now?
axis is a variable and can get values x,y,or z.
MPoint has methods MPoint::x,MPoint::y and MPoint::z
So axis tells which one of those should be used,you understand now?
Quote:Original post by TheMan22Ah, I see. Then you'll want something like:
MPoint does not have axis method.
axis is a variable and can get values x,y,or z.
MPoint has methods MPoint::x,MPoint::y and MPoint::z
So axis tells which one of those should be used,you understand now?
if(axis == "x" && point.x == 0){ // Whatever}else if(axis == "y" && point.y == 0){ // Whatever}else if(axis == "z" && point.z == 0){ // Whatever}
Assuming C++, that is. Also note that string comparisons are case sensitive.
no other way to do this ?
I must use if statements?
In mel for example you do this :
polyCube -name "some" // means create a 3d cube called some
And you can do something like this :
string $name = " -name ";
eval("polyCube" + $name + "\"some\"");
I must use if statements?
In mel for example you do this :
polyCube -name "some" // means create a 3d cube called some
And you can do something like this :
string $name = " -name ";
eval("polyCube" + $name + "\"some\"");
Quote:Original post by TheMan22The other solutions are to use a switch, a map, or both together. But the logic you have to program is the same; you have to manually map each possible input, with the proper code to execute.
no other way to do this ?
I must use if statements?
Quote:In mel for example you do this :That's because mel is apparently a scripting language. Scripting languages allow you to call variables by name. Compiled languages don't even store the names of variables in memory.
polyCube -name "some" // means create a 3d cube called some
And you can do something like this :
string $name = " -name ";
eval("polyCube" + $name + "\"some\"");
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement