{"id":230,"date":"2008-09-05T07:22:06","date_gmt":"2008-09-05T14:22:06","guid":{"rendered":"http:\/\/www.rodgreen.com\/?p=230"},"modified":"2008-09-05T07:22:06","modified_gmt":"2008-09-05T14:22:06","slug":"how-do-i-key-an-attribute-thats-constrained","status":"publish","type":"post","link":"https:\/\/www.rodgreen.com\/?p=230","title":{"rendered":"How do I key an attribute that&#8217;s constrained?"},"content":{"rendered":"<p>This solution only realy applies to &#8216;constrained&#8217; attributes and not expression or other forms of driven control.<\/p>\n<div>\n<p><a target=\"_blank\" href=\"https:\/\/www.rodgreen.com\/scripts\/mel\/keyConsAttrib.mel\">[Download]<\/a><\/p>\n<p><!--more--><\/p>\n<pre style=\"margin-left: 40px; \">\nproc keyConsAttrib(string $inputObjs[], string $attributes[], float $startTime, float $endTime, float $inc)\n{\n\tfloat $curTime = currentTime(&quot;-q&quot;);\n\n\tfor($eachObj in $inputObjs)\n\t{\n\t\tcurrentTime($startTime);\n\n\t\tfor($eachAttr in $attributes)\n\t\t{\n\t\t\tstring $fullAttr = ($eachObj + &quot;.&quot; + $eachAttr);\n\t\t\tstring $listConnResult[] = listConnections(&quot;-s&quot;, 1, $fullAttr);\n\t\t\tif(nodeType($listConnResult[0]) != &quot;pairBlend&quot;)\n\t\t\t{\n\t\t\t\t\n\t\t\t\tsetKeyframe($fullAttr);\n\t\t\t\t$listConnResult = listConnections(&quot;-s&quot;, 1, $fullAttr);\n\t\t\t}\n\n\t\t\tstring $pairBlend = $listConnResult[0];\n\n\t\t\t$listConnResult = listConnections(&quot;-s&quot;, 1, &quot;-p&quot;, 1, ($pairBlend + &quot;.weight&quot;));\n\t\t\tstring $weightSource = $listConnResult[0];\n\n\t\t\tsetAttr($weightSource, 1);\n\n\n\t\t}\n\t}\n\tcurrentTime($curTime);\n\n\tfor($curTime = $startTime; $curTime &lt;= $endTime; $curTime += $inc)\n\t{\n\n\t\tfor($eachObj in $inputObjs)\n\t\t{\n\t\t\tfor($eachAttr in $attributes)\n\t\t\t{\n\t\t\t\tstring $fullAttr = ($eachObj + &quot;.&quot; + $eachAttr);\n\t\t\t\tfloat $value = getAttr(&quot;-time&quot;, $curTime, $fullAttr);\n\t\t\t\tsetKeyframe -time $curTime -value $value $fullAttr;\n\t\t\t}\n\t\t}\n\t}\n\n}\n<br type=\"_moz\" \/><\/pre>\n<p>Usage:<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin-left: 40px; \">\nkeyConsAttrib(ls(&quot;-selection&quot;, &quot;-long&quot;), {&quot;tx&quot;,&quot;ty&quot;,&quot;tz&quot;,&quot;rx&quot;,&quot;ry&quot;,&quot;rz&quot;}, 0, 30, 1);\n<br type=\"_moz\" \/><\/pre>\n<p><a target=\"_blank\" href=\"https:\/\/www.rodgreen.com\/scripts\/mel\/keyConsAttrib.mel\">[Download]<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This solution only realy applies to &#8216;constrained&#8217; attributes and not expression or other forms of driven control. [Download]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,7,11,15],"tags":[54,37,41,56,58],"class_list":["post-230","post","type-post","status-publish","format-standard","hentry","category-art","category-maya-art","category-technical-art","category-tutorials","tag-maya-art","tag-mel","tag-python","tag-technical-art","tag-tutorials"],"_links":{"self":[{"href":"https:\/\/www.rodgreen.com\/index.php?rest_route=\/wp\/v2\/posts\/230","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rodgreen.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rodgreen.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rodgreen.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rodgreen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=230"}],"version-history":[{"count":0,"href":"https:\/\/www.rodgreen.com\/index.php?rest_route=\/wp\/v2\/posts\/230\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rodgreen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=230"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rodgreen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=230"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rodgreen.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=230"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}