Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Maya® / MEL / Maya MEL not working dynamically - Why?
  RSS 2.0 ATOM  

Maya MEL not working dynamically - Why?
Rate this thread
 
63725
 
Permlink of this thread  
avatar
  • Total Posts: 24
  • Joined: 26 July 2011 02:33 PM

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);   
}
********************************************************


Replies: 0
avatar
  • svv3d
  • Posted: 20 January 2012 11:15 PM

use scriptJob
http://melscriptingfordummies.bl...ng-what-is-scriptjob.html



Replies: 1
/img/forum/dark/default_avatar.png

Thanks, but it didn’t come to be useful, although relative.

Author: mostafatalebi

Replied: 21 January 2012 06:09 AM  
avatar

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 $vNamestring $vCurvestring $scaleCurvestring $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 [0]`;
 
string $vIkHandle $connections [0];
 
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 [$i] ".scale" $fa);
 
}
 
 setAttr 
($scaleCurve ".visibility"0;
}


Replies: 0