I am making a custom morph between two target shapes by making the vertex position of my base shape equal to the average of two target shapes' vertexes on a one to one basis.
the problem is that when I make a loop, I get a syntax error when I plug the variable $counter into the place where the vertex index needs to be.
here is how the statement by itself looks (this version works):
When working with numbered verts like that, the name of the vertex is treated as a string. So just plugging in a variable between the brackets doesn't work. You need to build it up as a string.
Now onto the syntax of your equals statement. Attribute vallues cannot be simply set by assigning a value through equality like you would with a variable.
So lets give this a shot...
int $counter = 1; //This set up to go from 2 through 5, that seems a bit odd... while ($counter < 6) { $counter = ($counter + 1);
//Build the name of the vertex string string $vertexPntxName = ("baseShape.pnts[" + $counter + "].pntx");
//Retrieve the attr values we need float $targetAShapeValue = getAttr targetAShape.pnts[2].pntx; float $targetBShapeValue = getAttr targetBShape.pnts[2].pntx; float $valueToAssign = ($targetAShapeValue *100) + ($targetBShapeValue *100) / 200); //btw, *100 /200 is the same as *0.5
//Set attribute value setAttr $vertexPntxName $valueToAssign; }
I think that is correct, anyway. I don't work much with morph target so I am not used to dealing with the pntx stuff.
Actually now that I look at it it seems that you original attempt looks a lot like an expression, so maybe this is all completely worthless to you Oh well.
isnt this a bit painfully slow... using expressions with direct connections should give you much faster perfroemance! And not using getattr in them at all!