I should have said that you should put this stuff in your menu.py (or
somewhere else in your plugin path). Here's a working example which adds a
size auto label to Blur nodes:

def blurAL():
    tn = nuke.thisNode()
    name = tn.name()
    size = ' (%s)' % tn['size'].value()
    label = [name+size]
    user_label = tn['label'].value()
    if user_label:
        label.append(user_label)
    return '\n'.join(label)

nuke.addAutolabel(blurAL, nodeClass='Blur')




On Fri, Oct 28, 2011 at 1:16 AM, woei lee <[email protected]> wrote:

> BTW, if we add the user ['label'] to autolabel callback,
> and if we have tcl in ['label'], it doesn't show the result from that tcl,
> ie: it would show,
> [value format.width] x [value format.height]
> instead of
> 1920x1080
>
>
>
> On Thu, Oct 27, 2011 at 1:33 PM, woei lee <[email protected]> wrote:
>
>>
>> Hi Ean,
>> Thanks for the replied, I appreciate it.
>>
>> I don't quite understand, pardon my lack of knowledge.
>>
>> for example,
>>
>> ##
>>
>> def autolabelCallback( ):
>>
>> n = nuke.thisNode()
>>
>> label = "myLabel"
>>
>>  return label
>>
>> node = nuke.createNode( 'Read' )
>>
>> node['autolabel'].setValue( 'autolabelCallback()' )
>>
>> print node['autolabel'].value()
>> ##
>>
>>
>> the result I got is
>>
>> # Result:
>>
>> autolabelCallback()
>>
>>
>> instead, is there a way to get the value as "myLabel"?
>>
>>
>> Thanks again!
>> -W
>>
>>
>>
>>
>> On Thu, Oct 27, 2011 at 12:35 PM, Ean Carr <[email protected]> wrote:
>>
>>> Hi,
>>>
>>> To do autolabels, define a function that returns a string, then add it
>>> using nuke.addAutolabel. For example:
>>>
>>> ###
>>> def myAutolabel():
>>>     return 'myLabel'
>>>
>>> nuke.addAutolabel(myAutolabel)
>>> ###
>>>
>>> You can specify a nodeClass kwarg, too:
>>>
>>> nuke.addAutolabel(myAutolabel, nodeClass='Blur') # Blur nodes only
>>>
>>> If you want to keep indicators on custom autolabels, you can put this in
>>> your autolabel function:
>>>
>>> ###
>>> ind =
>>> nuke.expression("(keys?1:0)+(has_expression?2:0)+(clones?8:0)+(viewsplit?32:0)")
>>> if int(nuke.numvalue("maskChannelInput", 0)) :
>>>     ind += 4
>>> if int(nuke.numvalue("this.mix", 1)) < 1:
>>>     ind += 16
>>> nuke.knob("this.indicators", str(ind))
>>> ###
>>>
>>> Oh, and finally, you have to also return the user's label or it won't
>>> show up, i.e. nuke.thisNode()['label'].value().
>>>
>>> It's useful to build a list where each index is a line of your node's
>>> label, join it up with '\n'.join(mylist), then return that string.
>>>
>>> Hope this helps.
>>>
>>> Cheers,
>>> Ean
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Thu, Oct 27, 2011 at 7:47 PM, woei lee <[email protected]> wrote:
>>>
>>>>
>>>>
>>>> Hello all,
>>>>
>>>>
>>>> If I def a method ( def autolabelCallback() ) and assign a custom value
>>>> to a node's ['autolabel'], ie: 'myLabel'
>>>>
>>>>
>>>> But now when I print from ['autolabel'], it's printing 
>>>> "autolabelCallback()",
>>>> how do I get "myLabel" instead?
>>>>
>>>>
>>>> Thanks!
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Nuke-python mailing list
>>>> [email protected], http://forums.thefoundry.co.uk/
>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>>>
>>>>
>>>
>>> _______________________________________________
>>> Nuke-python mailing list
>>> [email protected], http://forums.thefoundry.co.uk/
>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>>
>>>
>>
>
> _______________________________________________
> Nuke-python mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
>
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to