PDA

View Full Version : Variables not being computed


PeterRabel
02-11-2011, 06:56 PM
I am having some trouble with a part of a script I'm writing that uses a point on poly constraint.

when I do a point on poly constraint, maya outputs this code:

doCreatePointOnPolyConstraintArgList 1 { "0","0","0","1","","1" };
string $constraint[]=`pointOnPolyConstraint -weight 1`;
setAttr ($constraint[0]+".dragonU0") 0.568750;
setAttr ($constraint[0]+".dragonV0") 0.339353;

I kept the code identical, just changed the U and V values from the numbers to float variables with equivalent values.

float $uTest = 0.568750;
float $vTest = 0.339353;


doCreatePointOnPolyConstraintArgList 1 { "0","0","0","1","","1" };
string $constraint[]=`pointOnPolyConstraint -weight 1`;
setAttr ($constraint[0]+".dragonU0") $uTest;
setAttr ($constraint[0]+".dragonV0") $vTest;

I have no idea why it isn't reading the variables as the values they represent. This is very frustrating, any help would be much appreciated.

NaughtyNathan
02-11-2011, 07:27 PM
I have no idea what this "pointOnPolyConstraint" command is as it's not available in my Maya 2010, so I'm assuming it's something new in 2011 or a plug-in... however, the first line may well be the runTimeCommand or the MEL script that performs the whole function, which in turn is printing out the following three lines of code. This happens a lot in MEL, especially when you have "Echo All Commands" turned on. The first line is the only line you need to perform the operation using the defaults, but that is actually just a "short-cut" or "alias" to the following code. If you run it ALL like you are doing you are actually performing your desired operation twice (except the second time is probably failing because your selection list has changed and is now inappropriate for the command).

In other words, ditch the first line and use the last 3 lines only.

:nathaN

PeterRabel
02-11-2011, 08:31 PM
Thank you for the reply Nathan.
The point on poly constraint is indeed a new addition in 2011.
I get the same results using just this:
float $uTest = 0.339353;
float $vTest = 0.553125;
string $constraint[]=`pointOnPolyConstraint -weight 1`;
setAttr ($constraint[0]+".dragonU0") $uTest;
setAttr ($constraint[0]+".dragonV0") $vTest;
But you are correct in that the first line isn't needed, using just this code works.
string $constraint[]=`pointOnPolyConstraint -weight 1`;
setAttr ($constraint[0]+".dragonU0") 0.568750;
setAttr ($constraint[0]+".dragonV0") 0.339353;
So I threw out that line, but I am still having the same problem. using the code with the variables doesn't return an error, in fact it does create a point on poly constraint node attached to the correct object. The issue is that it does nothing. As if it isn't connected to anything.

haggi
02-12-2011, 09:45 PM
Did you select the object before executing the commands? If no error is returned and an constraint is created, it seems that there were no objects selected to attach to. Maybe you can try something like this (I'm not sure about the order of the objects):

string $constraint[]=`pointOnPolyConstraint -weight 1 constrainObj baseObj`;
Where constrainObj and baseObj are the objects in your scene.

PeterRabel
02-12-2011, 09:55 PM
Yes I had the objects selected and in the correct order. I have tried running the maya generated code, undoing the operation and without changing anything, running the code with the variables. It's connecting the constraint node properly, but it's not assigning any UV coordinates to lock the object to.

CGTalk Moderation
02-12-2011, 09:55 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.