Great thanks, 

t. 


-----------------------
Tahl Niran
vfx compositor
www.tahlniran.com



Date: Thu, 12 May 2011 08:29:23 -0700
Subject: Re: [Nuke-python] rotopaint view left, right
From: [email protected]
To: [email protected]

Here:
http://pastebin.com/ViZa5i9g
See if that helps.
Cheers,Ivan


On Thu, May 12, 2011 at 4:19 AM, Tahl Niran <[email protected]> wrote:






Sorry to dig this old thread up but...

Did anyone come up with  a nice script to actually set Rotopaint nodes to be 
both Left and Right views ? 

-----------------------
Tahl Niran
vfx compositor
www.tahlniran.com



> Subject: Re: [Nuke-python] rotopaint view left, right
> From: [email protected]

> Date: Thu, 23 Sep 2010 11:11:14 +1200
> To: [email protected]
> 
> use pastebin.com if you have trouble with lost formatting, it's great!

> 
> On Sep 23, 2010, at 1:59 AM, Michael wrote:
> 
> > Some of the formatting was lost as I typed it in ... hopefully this won't 
> > lose it.
> > 
> > The first function (get_rotopaint_views) returns a list of the views used 
> > ... run it with a print statement in the script editor to see its results 
> > in the script editor.  The second function (set_rotopaint_views) needs to 
> > be provided with the view name (as a string) that you want to set it to ... 
> > the earlier one would set it but not update the GUI, this one will do both. 
> >  They both work fine on my Mac or on Linux.  Note that I haven't shown you 
> > how to set the View to multiple views ... mainly cause I haven't figured 
> > out exactly how you do that.  There are LOTS of ways in which the RotoPaint 
> > is buggy as hell when trying to access stuff through Python, so be warned.

> > 
> > import nuke.rotopaint
> > 
> > def get_rotopaint_views(node):
> >    views_used = set()
> >    knob = node['curves']
> >    for element in knob.rootLayer:

> >        if isinstance(element, nuke.rotopaint.Stroke) or isinstance(element, 
> > nuke.rotopaint.Shape):
> >            attrs = element.getAttributes()
> >            for i in range(attrs.getValue(1, attrs.kNumberOfViewsAttribute)):

> >                views_used.add(nuke.views()[int(attrs.getValue(1, '%s%s' % 
> > (attrs.kViewAttribute, i+1)))-1])
> > 
> >    return [v for v in nuke.views() if v in views_used]
> > 

> > def set_rotopaint_view(node, view):
> >    view_index = nuke.views().index(view) + 1
> >    knob = node['curves']
> >    for element in knob.rootLayer:
> >        if isinstance(element, nuke.rotopaint.Stroke) or isinstance(element, 
> > nuke.rotopaint.Shape):

> >            attrs = element.getAttributes()
> >            attrs.set(1, '%s%s' % (attrs.kViewAttribute, 1), view_index)
> >            knob.setFlag(nuke.INVISIBLE)
> >            knob.clearFlag(nuke.INVISIBLE)

> > 
> > 
> > for test in nuke.allNodes('RotoPaint'):
> >     print '%s = %s' % (test.name(), get_rotopaint_views(test))
> > 

> >     print '%s - setting left' % test.name()
> >     set_rotopaint_view(test, 'left')
> >     print '%s = %s' % (test.name(), get_rotopaint_views(test))

> > 
> >     print '%s - setting right' % test.name()
> >     set_rotopaint_view(test, 'right')
> >     print '%s = %s' % (test.name(), get_rotopaint_views(test))

> > 
> > On Sep 22, 2010, at 3:57 AM, Olivier Jezequel wrote:
> > 
> >> Thanks for sharing that, i wouldn't have figured that alone.
> >> Is the return is supposed to give back something ?? it doesn't when i try

> >> In fact none of the scripts are giving me any result. I have no error 
> >> (fixed the , at the end) but no change or printed action happen.
> >> I may have missed something
> >> 
> >> thanks again for that

> >> 
> >> Michael M wrote:
> >>> Sadly, and I say this because I spent HOURS of my life figuring out
> >>> something that should have been made MUCH more clear by the people

> >>> that wrote it, I do know how to do this:
> >>> 
> >>> import nuke.rotopaint
> >>> 
> >>> def get_rotopaint_views(node):
> >>>   views_used = set()

> >>>   knob = node['curves']
> >>>   for element in knob.rootLayer:
> >>>       if isinstance(element, nuke.rotopaint.Stroke) or
> >>> isinstance(element, nuke.rotopaint.Shape):

> >>>           attrs = element.getAttributes()
> >>>           for i in range(attrs.getValue(1, 
> >>> attrs.kNumberOfViewsAttribute)):
> >>>               views_used.add(nuke.views()[int(attrs.getValue(1,

> >>> '%s%s' % (attrs.kViewAttribute, i+1)))-1])
> >>> 
> >>>   return [v for v in nuke.views() if v in views_used]
> >>> 
> >>> That's how you get it ... setting it is a little wonky ... well, a

> >>> lot, and I haven't explored it as much:
> >>> 
> >>> def set_rotopaint_views(node, view):
> >>>   view_index = nuke.views().index(view) + 1
> >>>   knob = node['curves']

> >>>   for element in knob.rootLayer:
> >>>       if isinstance(element, nuke.rotopaint.Stroke) or
> >>> isinstance(element, nuke.rotopaint.Shape):
> >>>           attrs = element.getAttributes()

> >>>           attrs.set(1, '%s%s' % (attrs.kViewAttribute, 1), view_index)
> >>> set_rotopaint_views(nuke.selectedNode(). 'left')
> >>> 
> >>> Michael

> >>> 
> >>> On Tue, Sep 21, 2010 at 12:53 PM, Olivier Jezequel
> >>> <[email protected]> wrote:

> >>> 
> >>>> Hiya again,
> >>>> how do you access the view attribute inside the rotopaint tool 
> >>>> (nuke6.0v7)
> >>>> when you pass your comp into a stereo setup, your roto/paints are set on

> >>>> 'left' only by default
> >>>> i try to make a script that change it to left, right. As you can have a 
> >>>> lot
> >>>> of strokes or roto to change.
> >>>> 

> >>>> any idea ?
> >>>> 
> >>>> cheers
> >>>> Olivier
> >>>> 
> >>>> 
> >>>> _______________________________________________

> >>>> 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
> >>> 
> >> 

> >> _______________________________________________
> >> 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

> 
> _______________________________________________
> Nuke-python mailing list
> [email protected]
> 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