Maya MEL not working dynamically - Why?

Maya MEL not working dynamically - Why?

Anonymous
Not applicable
468 Views
3 Replies
Message 1 of 4

Maya MEL not working dynamically - Why?

Anonymous
Not applicable
Hello
How I should make a dynamic script that at a certain time when I do a job in Maya the script evaluate that, currently it just applies information at the time of execution.(I need script be evaluating constantly rather than static evaluation at the time of execution)

Here is more information:

I have written a MEL script doing the job of both the multiplyDivide node and Condition Node of maya at the same time for extending the joint.scale value when needed.

Regularly we use two Maya node to say to Maya that if our Ik curve is scaled in a certain direction, and if that scale exceeds the scale of relative joints, do add a particular value(result from a particular formulations as you know) to the relative axis of the joint.


Now when I run the script it get executed correctly but since at that time the conditional value is false(is $crv_length smaller than $num or the same) nothing happens even when I scale the IK curve. After all how I should make the script dynamic.

Here is the code:

*********************************************************
float $crv_Length = `getAttr ctrl_info1.arcLength`;
float $num = 9.662;
if ($crv_Length > $num)
{
float $resultCrv = $crv_Length / $num;
float $test_1 = `getAttr test1.scaleX`;
setAttr $test_1 ($test_1 + $crvLength);
float $test_2 = `getAttr test2.scaleX`;
setAttr $test_2 ($test_2 + $crvLength);
float $test_3 = `getAttr test3.scaleX`;
setAttr $test_3 ($test_3 + $crvLength);
float $test_4 = `getAttr test4.scaleX`;
setAttr $test_4 ($test_4 + $crvLength);
}
********************************************************
0 Likes
469 Views
3 Replies
Replies (3)
Message 2 of 4

svv3d
Enthusiast
Enthusiast
0 Likes
Message 3 of 4

Anonymous
Not applicable
Thanks, but it didn't come to be useful, although relative.
0 Likes
Message 4 of 4

Anonymous
Not applicable
Try this one.
create a duplicate of the ik curve and you can use the following code. i think this serves the purpose.


$vname is the character prefix,
$vcurve is the ikcurve,
$scalecurve is the duplicate of the ikcurve,
$fa is the joint followaxis

global proc createStretchSetupForSplineJoints (string $vName, string $vCurve, string $scaleCurve, string $fa)
{
string $arcLengthNode = `arclen -ch on $vCurve`;
$arcLengthNode = `rename $arcLengthNode ($vName + "_Cin")`;

string $arcLengthNode2 = `arclen -ch on $scaleCurve`;
$arcLengthNode2 = `rename $arcLengthNode2 ($vName + "_2_Cin")`;

string $vShape = `listRelatives -s $vCurve`;
string $connections = `listConnections -type ikHandle $vShape `;
string $vIkHandle = $connections ;
string $joints = `ikHandle -q -jl $vIkHandle`;
float $vLength = `getAttr ($arcLengthNode + ".arcLength")`;

string $scaleMdNode01 =`createNode multiplyDivide -n ($vName + "_Normal_Scale_Mdnode_Mdn")`;
setAttr ( $scaleMdNode01 + ".operation" ) 2;
connectAttr -force ( $arcLengthNode + ".arcLength" ) ( $scaleMdNode01 + ".input1X" );
connectAttr -force ( $arcLengthNode + ".arcLength" ) ( $scaleMdNode01 + ".input2X" );
connectAttr -force ( $arcLengthNode + ".arcLength" ) ( $scaleMdNode01 + ".input1Y" );
connectAttr -force ( $arcLengthNode2 + ".arcLength" ) ( $scaleMdNode01 + ".input2Y" );

string $scaleMdNode02 =`createNode multiplyDivide -n ($vName + "_Global_Scale_MdNode_Mdn")`;
connectAttr -force ( $scaleMdNode01 + ".outputY" ) ( $scaleMdNode02 + ".input1X" );
setAttr ( $scaleMdNode02 + ".operation" ) 2;
float $scaleMdNode02input1x = `getAttr ( $scaleMdNode02 + ".input1X" )`;
setAttr ( $scaleMdNode02 + ".input2X" ) $scaleMdNode02input1x;

for ($i = 1; $i < `size $joints`; $i++)
{
connectAttr -force ($scaleMdNode02 + ".outputX") ($joints + ".scale" + $fa);
}

setAttr ($scaleCurve + ".visibility") 0;
}
0 Likes