The & 1 is a binary AND. Indicators are integer bit flags that are packed
together into a single flag, in which each indicator occupies a different
bit.

In practice, it means each indicator has a nominal value (animation = 1,
expressions = 2, using mask_input = 4, etc.). Then they're added together.
So, if there's only an animation indicator, the flag value is 1, if there's
animation and expressions, the flag is 3.

The & 1 checks for any flag number that has the first bit (animation) set to
1. If you remove that, the function will still report the nodes that are
animated, but also nodes that have any other kind of indicators. For
example, a node that has an expression (but no animated keys) would have an
indicator flag of value 2, and removing the & 1 would also return true. You
can have a look into autolabel.py to see how indicators are being set.

Here's a couple of examples which will hopefully help explain this better:

def isAnimated(node):

# return True when the first bit is "on" (animations)

return bool(int(node['indicators'].value()) & 1)


 def hasExpression(node):

# return True when the second bit is "on" (expressions)

return bool(int(node['indicators'].value()) & 2)



Also, these should work regardless of whether a node is selected or not.

The following seems to work for me on your group of nodes:


def isAnimated(node):

return bool(int(node['indicators'].value()) & 1)

for n in nuke.allNodes():

print n['name'].value(), isAnimated(n)



Finally, I just took a peek myself at autolabel.py, I you could use the same
methods used in there, instead of relying on the indicators themselves. So,
checking whether a node is animated or not can also be done like this:


def isAnimated(node):

return bool(nuke.runIn(node.fullName(), "nuke.expression('keys')"))



Hope that helps.


Cheers,

Ivan





On Wed, Mar 9, 2011 at 10:48 PM, Howard Jones <[email protected]>wrote:

> Great! -
> Yes I was thinking that might be the only option though wouldn't have found
> indicators - one dumb question what does the '& 1' do at the end?
> seems to work without it too.
>
>
> Only seems to work with selected nodes so Ive just tested this and gives me
> what I want - thanks (probably easier way no doubt).
> Looping through nuke.allNodes() seems to just give knobs list
>
>
>  def isAnimated(node):
>
> return int(node['indicators'].value()) & 1
>
>
> for n in nuke.allNodes():
>
> n.setSelected(False)
>
> for n in nuke.allNodes():
>
> n.setSelected(True)
>
> i=isAnimated(nuke.selectedNode())
>
> print n['name'].value(),i
>
> n.setSelected(False)
>
>
> # Result:
>
> Blur1 1
>
> Transform1 0
>
> Viewer1 0
>
>
> for
>
>
> set cut_paste_input [stack 0]
> version 6.2 v2
> push $cut_paste_input
> Transform {
> center {960 540}
> name Transform1
> selected true
> xpos -148
> ypos 223
> }
> Blur {
> inputs 0
> size {{curve x1 0 x14 20 x32 0 x45 20}}
> name Blur1
> selected true
> xpos -255
> ypos 206
> }
>
> H
>
>
> ------------------------------
> *From:* Ivan Busquets <[email protected]>
> *To:* Nuke Python discussion <[email protected]>
> *Sent:* Thu, 10 March, 2011 0:42:34
> *Subject:* Re: [Nuke-python] node animated
>
> If you can rely on testing for whether the node has the "animated"
> indicator or not, you could do this:
>
> def isAnimated(node):
>     return int(node['indicators'].value()) & 1
>
> Basically, just check if the node has the "animated" indicator/icon.
> Would that work for you?
>
>
> On Wed, Mar 9, 2011 at 4:32 PM, Nathan Rusch <[email protected]>wrote:
>
>>   Not to my knowledge. I think you’ll probably just have to use a knob
>> loop.
>>
>> -Nathan
>>
>>
>>  *From:* Howard Jones <[email protected]>
>> *Sent:* Wednesday, March 09, 2011 4:06 PM
>> *To:* Nuke Python discussion <[email protected]>
>> *Subject:* [Nuke-python] node animated
>>
>>  Hi
>> Is there a way to check if a node contains an animation?
>>
>> like knob.isAnimated() but at node level?
>>
>> I've looked but cant find one.
>>
>> Cheers
>> H
>>
>>  ------------------------------
>> _______________________________________________
>> Nuke-python mailing list
>> [email protected]
>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>
>> _______________________________________________
>> Nuke-python mailing list
>> [email protected]
>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>
>>
>
> _______________________________________________
> Nuke-python mailing list
> [email protected]
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
>
_______________________________________________
Nuke-python mailing list
[email protected]
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to