Thats awesome (Your response. Not the bug). I really appreciate the detailed
solution!
On Mar 26, 2012, at 12:03 PM, Nathan Rusch wrote:
> There is some inconsistency in the behavior of the file knob's internal
> knob_changed callback (the one that sets file_type, which then creates or
> destroys the format-dependent knobs) depending on whether the node's control
> panel is open.
>
> To get around this in a knobChanged callback on your file knob, you can do
> the following:
>
> 1) Parse the extension off the new value
> 2) Temporarily set the KNOB_CHANGED_RECURSIVE flag on the file_type knob
> 3) Set the file_type knob
> 4) Clear the aforementioned flag
> 5) Check if the format actually changed and make sure the extension is valid
> and, if so, make your format-specific changes to the dynamic knobs.
>
> There is one other very important thing to note about this process: If you
> make changes to the format-dependent knobs in a GUI session, you must reset
> them to their default values before changing file_type knob programmatically
> again. If you fail to do this, Nuke will crash immediately, regardless of
> whether KNOB_CHANGED_RECURSIVE is set (this is logged as bug #21137, so if
> you ping support about it, it may get bumped up the priority list).
>
> def sampleKnobChanged():
> n = nuke.thisNode()
> k = nuke.thisKnob()
> if k is n['file']:
> ft = n['file_type']
> old = ft.value()
> buf = k.value().rsplit('.', 1)
> if len(buf) == 1: # No extension
> return
> # MAKE SURE TO RESET ANY FORMAT-DEPENDENT KNOBS
> # YOU CHANGED LAST TIME TO THEIR DEFAULTS HERE
> ft.setFlag(nuke.KNOB_CHANGED_RECURSIVE)
> ft.setValue(buf[1])
> ft.clearFlag(nuke.KNOB_CHANGED_RECURSIVE)
> new = ft.value().strip()
> if (not new) or new == old: # Same or invalid extension
> return
> # Should be in good shape to do your compression changes here
>
>
> Hope this makes sense,
>
> -Nathan
>
> -----Original Message----- From: Justin Israel
> Sent: Monday, March 26, 2012 11:03 AM
> To: Nuke Python discussion
> Subject: Re: [Nuke-python] file_type specific knobs not immediately avail
> inWrite node callback?
>
> ::bump::
> Nothing on this anyone?
>
>
> On Mar 22, 2012, at 6:38 PM, Justin Israel wrote:
>
>> This is a somewhat similar situation to something Bjorn Fredriksson asked on
>> Nov 16, regarding crashes in a gizmo that wraps a Write node.
>>
>> I also have a Gizmo that wraps a Write node and exposes only very basic
>> custom knobs. One thing I am doing right now in a knobChanged callback is to
>> check the file_type and set certain relevant compression settings.
>> Specifically, for example, when tif is selected from the file_type dropdown,
>> I ensure that LZW is set in the compression knob.
>> This currently works fine when the callback is responding to the file_type
>> knob being directly changed, but when I change the file extension in the
>> file knob to .tif, the same callback code can't see the compression knob
>> existing yet.
>>
>> Am I missing something about how I am referencing the node in the callback,
>> or some deferred action taking place to update the Write nodes file_type
>> specific compression knob?
>> When I test this manually from the script editor, I can change the extension
>> in the file knob and then check the value of the compression knob and it
>> does exist. I must be somehow checking before the Write node has updated
>> itself.
>>
>> -- justin
>>
>> _______________________________________________
>> 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