The lifetime knob is a new thing, as you mention, and it can also be
renamed. Using the User tab may be better and more
back-compatible; although it can be renamed it probably won't, but I do
know of studios which do.

I think the reason there isn't an API for this is, because of time
constraints, no-one had time to ensure such an api would be robust in an
add/remove/shuffle-whilst-iterating scenario. I did look at doing this a
couple of years ago but there were a couple of other tricky (e.g. not
solvable between builds) edge cases to address.

Your solution is what I think ended up doing myself, in Python.

F.

On Wednesday, January 21, 2015, Johannes Saam <johannes.s...@gmail.com>
wrote:

> for the record here is a way to get a list of all user knobs.... the if
> statement starting the recording of knobs is stable for now but could
> change in the future so watch out
>
> std::vector<DD::Image::Knob*> MyOp::getUserKnobs() const
> {
>     // the output buffer
>     std::vector<DD::Image::Knob*> userKnobs;
>
>     // flag if we start recording knobs yet as 'user' knobs
>     bool userStarted = false;
>
>     // run over all knobs by index
>     for( int i = 0;; i++ )
>     {
>         // candidate knob
>         DD::Image::Knob * k = DD::Image::Op::knob(i);
>
>         // valid knob on i
>         if ( k )
>         {
>             // do not record tab knobs at all
>             if ( strcmp( k->Class(), "Tab_Knob" ) == 0 )
>                 continue;
>
>             // if we have identified the last knob
>             // in the node tab we start recording
>             // using the User label on a tab is not
>             // safe as the user knobs tab can be renamed
>             if ( userStarted )
>             {
>                 // add a this knob to the result list
>                 userKnobs.push_back( k );
>             }
>             else
>             {
>                 // not recording yet, lets see if we reached the last knob
>                 // this might change with nuke changing works for nuke9v1
>                 if ( strcmp( k->Class(), "Boolean_Knob" ) == 0 &&
> k->name() == "useLifetime" )
>                 {
>                     // from here onwards we record all knobs
>                     userStarted = true;
>                 }
>             }
>         }
>         else
>         {
>             break;
>         }
>     } // done iterating knobs
>
>     return userKnobs;
> }
>
> On Tue, Jan 20, 2015 at 3:45 PM, Johannes Saam <johannes.s...@gmail.com
> <javascript:_e(%7B%7D,'cvml','johannes.s...@gmail.com');>> wrote:
>
>> Damn thats sucking. What would you suggest then how to access all the
>> user created knobs? Iterate though all of the knobs and cross the ones i
>> know i added off the list?! Of course i create knobs via the API
>> dynamically so tracking all this is quite a pain.
>>
>> I vote for a getUserKnobs function on DD::Image::Op . Anyone?
>>
>> Thanks
>> jo
>>
>> On Tue, Jan 20, 2015 at 11:17 AM, Nathan Rusch <nathan_ru...@hotmail.com
>> <javascript:_e(%7B%7D,'cvml','nathan_ru...@hotmail.com');>> wrote:
>>
>>>   If you're planning to look the tab up by name, it's worth keeping in
>>> mind that the "User" tab can be renamed.
>>>
>>> -Nathan
>>>
>>>
>>>  *From:* Johannes Saam
>>> <javascript:_e(%7B%7D,'cvml','johannes.s...@gmail.com');>
>>> *Sent:* Tuesday, January 20, 2015 10:25 AM
>>> *To:* Nuke plug-in development discussion
>>> <javascript:_e(%7B%7D,'cvml','nuke-dev@support.thefoundry.co.uk');>
>>> *Subject:* Re: [Nuke-dev] Acessing user knobs
>>>
>>>  Ok i will have another look. I had no idea i could get an ID for the
>>> user tab... the NDK docs will help for sure. It would be awesome to have a
>>> function on Op like std::vector<Knob*> & getUserKnobs().
>>>
>>> again should i be able to get it done i might share it here so we have
>>> it written down.
>>>
>>> Also the user knobs that nuke provides with the ( might need a rework??
>>> ) interface are not at all what nuke offers in terms of knobbage. Is there
>>> a way to hack more into it? As in is it a python script we can access and
>>> enlarge? I am on the fence now to write a c++ version so i can have more
>>> Knobs and then just store them under the user tab myself.... i keep yous
>>> posted.
>>>
>>> Thanks!
>>> JO
>>>
>>> On Tue, Jan 20, 2015 at 12:42 AM, Frank Harrison <fr...@thefoundry.co.uk
>>> <javascript:_e(%7B%7D,'cvml','fr...@thefoundry.co.uk');>> wrote:
>>>
>>>>   Hey,
>>>>
>>>> yes, that is a way. User-Knobs should always be on the "user" tab.
>>>>
>>>> This has come up before and I think we said that we'd add some pythonic
>>>> getter for UserKnobs if we got a few more requests for it.
>>>>
>>>> I think, but don't quote me on this, that you can get the tab-idx and
>>>> iterate from there. Perhaps there's something on Nukepedia
>>>> <http://www.nukepedia.com/> to do this for you?
>>>>
>>>> F.
>>>>
>>>>  On 20 January 2015 at 02:15, Johannes Saam <johannes.s...@gmail.com
>>>> <javascript:_e(%7B%7D,'cvml','johannes.s...@gmail.com');>> wrote:
>>>>
>>>>>  Hey Gang,
>>>>>
>>>>> is there an easy way to access knobs that have been created by the
>>>>> user with "manage user knobs"
>>>>> i know they are all in the "user" tab is that a way? I was hoping i
>>>>> could get all the user generated knobs and then act on them.
>>>>> Thanks!
>>>>> JO
>>>>>
>>>>> _______________________________________________
>>>>> Nuke-dev mailing list
>>>>> Nuke-dev@support.thefoundry.co.uk
>>>>> <javascript:_e(%7B%7D,'cvml','Nuke-dev@support.thefoundry.co.uk');>,
>>>>> http://forums.thefoundry.co.uk/
>>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>>  Frank Harrison
>>>> Senior Nuke Software Engineer
>>>> The Foundry
>>>> Tel: +44 (0)20 7968 6828 - Fax: +44 (0)20 7930 8906
>>>> Web: www.thefoundry.co.uk
>>>> Email: frank.harri...@thefoundry.co.uk
>>>> <javascript:_e(%7B%7D,'cvml','frank.harri...@thefoundry.co.uk');>
>>>>
>>>> _______________________________________________
>>>> Nuke-dev mailing list
>>>> Nuke-dev@support.thefoundry.co.uk
>>>> <javascript:_e(%7B%7D,'cvml','Nuke-dev@support.thefoundry.co.uk');>,
>>>> http://forums.thefoundry.co.uk/
>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev
>>>>
>>>>
>>>
>>> ------------------------------
>>> _______________________________________________
>>> Nuke-dev mailing list
>>> Nuke-dev@support.thefoundry.co.uk
>>> <javascript:_e(%7B%7D,'cvml','Nuke-dev@support.thefoundry.co.uk');>,
>>> http://forums.thefoundry.co.uk/
>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev
>>>
>>>
>>> _______________________________________________
>>> Nuke-dev mailing list
>>> Nuke-dev@support.thefoundry.co.uk
>>> <javascript:_e(%7B%7D,'cvml','Nuke-dev@support.thefoundry.co.uk');>,
>>> http://forums.thefoundry.co.uk/
>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev
>>>
>>>
>>
>

-- 
Frank Harrison
Senior Nuke Software Engineer
The Foundry
Tel: +44 (0)20 7968 6828 - Fax: +44 (0)20 7930 8906
Web: www.thefoundry.co.uk
Email: frank.harri...@thefoundry.co.uk
_______________________________________________
Nuke-dev mailing list
Nuke-dev@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev

Reply via email to