A much simpler way is to set a default label for the Blur, like this:
nuke.knobDefault("Blur.label", "[value size]")
It's a bit untidy, but for simple expressions like that, I think it's fine.
If you do want to use the autolabel callback, be aware the autolabel has
more subtly than just nodename+new text.. E.g it should:
* append the value of the 'label' knob
* set the animated/expression/clone/splitview indicator icons
* respect the preferences.autolabel setting
* show things like the selected layer and mask channels
Also a bunch of node-specific stuff - it's kind of convoluted.. Check
nuke_directory/plugins/autolabel.py
At the very least, you don't want to lose the indicators or the existing
label:
def _set_icons(node):
ind = nuke.runIn(node.fullName(),
'nuke.expression("(keys?1:0)+(has_expression?2:0)+(clones?8:0)+(viewsplit?32:0)")')
maskinput_act = int(nuke.runIn(node.fullName(),
'nuke.numvalue("maskChannelInput", 0)'))
if maskinput_act:
ind += 4
mix_act = nuke.runIn(node.fullName(),
'int(nuke.numvalue("this.mix", 1)) < 1')
if mix_act:
ind += 16
node['indicators'].setValue(ind)
def AL():
n=nuke.thisNode()
_set_icons(n)
label= '%s\n %s' %(n.name(), n['size'].value())
userlabel = n['label'].evaluate():
if len(userlabel) > 0:
label += "\n%s" % userlabel
return label
nuke.addAutolabel(AL, nodeClass='Blur')
On 03/05/13 07:05, Michael Garrett wrote:
Ah, thanks Nathan - I thought addAutoLabel() would only change the
'autolabel' hidden knob.
Googling some examples, this works better:
def AL():
n=nuke.thisNode()
label= '%s\n %s' %(n.name <http://n.name>(), n['size'].value())
return label
nuke.addAutolabel(AL, nodeClass='Blur')
On 2 May 2013 16:44, Nathan Rusch <[email protected]
<mailto:[email protected]>> wrote:
The behavior you’re seeing sounds like it’s in line with the
intended callback behavior:
"...If all of [the registered callbacks] return None, then
nuke.thisNode().name() is used"
-Nathan
*From:* Michael Garrett <mailto:[email protected]>
*Sent:* Thursday, May 02, 2013 1:38 PM
*To:* Nuke Python discussion
<mailto:[email protected]>
*Subject:* [Nuke-python] autoLabel is replacing name in dag
I'm finding that an autoLabel is replacing the node name in the dag,
for example:
def AL():
blurSize=nuke.thisNode()['size'].value()
return blurSize
nuke.addAutolabel(AL, nodeClass='Blur')
...then create a Blur node.
I'm on Windows 7, Nuke 7.0v5.
Thanks,
Michael
------------------------------------------------------------------------
_______________________________________________
Nuke-python mailing list
[email protected]
<mailto:[email protected]>,
http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________
Nuke-python mailing list
[email protected]
<mailto:[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
--
ben dickson
2D TD | [email protected]
rising sun pictures | www.rsp.com.au
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python