Hi Nathan and all

Thanks for that - it got me some way except in my case for stereo. Is there a 
way then to see if a knob has been split off?

The issue is working with your examples on nukepedia that if you pass a higher 
number into animation(n) than exists it segment faults Nuke (now Bug 17174  - 
nuke.animation causes segmentation fault )

So what I am trying to do is to find the number of fields so that I never go 
over the amount.

Below is the code I am working on - which for a mono project will take all 
selected keyframes in a selected node (haven't got round that bit yet) and 
pastes these further down the line. 

Ideally I would like to just get this from nuke.animations() but I cant see how 
to use that information and no-one has come back so I'm stuck.
Anyway clunky code but gets someway towards pasting at position, but doesn't 
paste into another curve. If I can get the exact number of fields (ie split or 
not) then this will work on multiviews otherwise it can only work on mono.


# gets segmentation fault unless you can figure out how many curves there are 
per knob
def pasteKeyframes():
  sn=nuke.selectedNodes()
  s=len(sn)
  numViews=len(nuke.views())
  if s :
  
    '''get the array size of the knob so that animation(num) doesn't cause a 
segmentation fault and check that
    the knob supports an arraySize() - note a couple of things also slip 
through'''
    for n in sn :
      firstKeyFound=0
      offset=0

      
      for k in n.knobs():
        try:
          ks=n[k].arraySize()
        except:
          ks=('wrong type')
        num=0
        i=0
        if ks is not 'wrong type':
          while num<ks:
            ''' get the number of keys on the curve'''
            try:
              na=n[k].animation(num)
              ns=na.size()

              
              '''step through the keys - check if they are selected the paste 
the values from timebar onwards'''
              while i < ns:
                  keySelected= (na.keys()[i].selected)
                  if keySelected:
                    firstKeyFound+=1
                    print k,ks,num
                    keyVals= (na.keys()[i].x, na.keys()[i].y)
                    if firstKeyFound==1:
                      offset=nuke.frame()-keyVals[0]
                    print ('keySelected: '+str(keySelected)+' keyvalues: 
'+str(keyVals)+' firstKeyFound: '+str(firstKeyFound)+ ' offset: '+str(offset))
                    na.setKey(keyVals[0]+offset,keyVals[1])
                  else:
                    print ('key not selected')
                  i+=1
            except AttributeError:
              pass
            num+=1
  else:
    nuke.message ('Please select a node as well as keyframes')


________________________________
From: Nathan Rusch <[email protected]>
>To: Howard Jones <[email protected]>; Nuke Python discussion 
><[email protected]>
>Sent: Monday, 7 March 2011, 18:43
>Subject: Re: [Nuke-python] knobs fields
>
>
>>
>I think you’re after <knob>.arraySize()
> 
>Keep in mind that this will only work with knobs inherited from Array_Knob. 
>And as far as multiple views go, you just need to multiply the arraySize() 
>value 
>by the number of views.
> 
>-Nathan
>
> 
>From: Howard Jones 
>Sent: Monday, March 07, 2011 10:38 AM
>To: Nuke Python discussion 
>Subject: [Nuke-python] knobs fields
>  Dear all
>
>
>
>Whats 
>the best way to determine the amount of fields a knob will have.
>ie 
>XY position knob has 2 fields but 4 in stereo (I think?)
>
>
>What 
>I'd like to do is query the knob and get an integer for its 
>fields.
>
>
>
>Any 
>help much appreciated
>
>
>Howard
>
> 
________________________________
 >_______________________________________________
>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