Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import nuke
- knobChangedCode = '''
- n = nuke.thisNode()
- k = nuke.thisKnob()
- geo_input = n.node('Geo')
- scene = n.node('Clones_Scene')
- curr = n.knob('current_num')
- if k.name() == 'number_of_clones':
- if k.value() > curr.value():
- for i in range(int(curr.value()), int(k.value())):
- to = nuke.nodes.TimeOffset()
- to.knob('time_offset').setExpression('parent.master_time_offset*%s' % str(i+1))
- to.setInput(0, geo_input)
- to.setXpos(geo_input.xpos()+(i+1)*200)
- to.setYpos(geo_input.ypos()+100)
- tr = nuke.nodes.TransformGeo()
- tr.setInput(0, to)
- tr.setXpos(to.xpos())
- tr.setYpos(to.ypos()+200)
- ax = nuke.nodes.Axis()
- for j,v in enumerate(['x','y','z']):
- ax.knob('translate').setExpression('parent.master_translate.%s' % v, j)
- ax.knob('rotate').setExpression('parent.master_rotate.%s' % v, j)
- ax.knob('scaling').setExpression('parent.master_scaling.%s' % v, j)
- ax.knob('skew').setExpression('parent.master_skew.%s' % v, j)
- ax.knob('uniform_scale').setExpression('parent.master_uniform_scale')
- ax.setXpos(tr.xpos()+100)
- ax.setYpos(tr.ypos()-100)
- if i == 0:
- node_to_connect = None
- else:
- node_to_connect = [ a for a in nuke.allNodes() if a.Class() == 'Axis' ][1]
- ax.setInput(0, node_to_connect)
- tr.setInput(1,ax)
- scene.setInput(i+1, tr)
- curr.setValue(k.value())
- '''
- def main():
- g = nuke.nodes.Group(name = 'Duplicate3D')
- newNameFormat = "%s%%d" % g.name()
- i = 1
- while nuke.exists(newNameFormat % i):
- i += 1
- g.setName(newNameFormat % i)
- t = nuke.Tab_Knob('Duplicate3D')
- # divider1 = nuke.Text_Knob('clones', 'Clones' )
- curr_num = nuke.Int_Knob('current_num')
- curr_num.setFlag(0x00040000)
- num_clones = nuke.Int_Knob('number_of_clones', 'number of clones')
- # divider2 = nuke.Text_Knob('time_offset', 'Time Offset')
- master_time_offset = nuke.Int_Knob('master_time_offset', 'time_offset')
- divider3 = nuke.Text_Knob( 'transform', 'Transform' )
- master_tr = nuke.XYZ_Knob('master_translate', 'translate')
- master_tr.setValue((1,0,0))
- master_rot = nuke.XYZ_Knob('master_rotate', 'rotate')
- master_scale = nuke.Scale_Knob('master_scaling', 'scale')
- master_size = nuke.Double_Knob('master_uniform_scale', 'uniform scale')
- master_size.setValue(1)
- master_skew = nuke.XYZ_Knob('master_skew', 'skew')
- divider4 = nuke.Text_Knob( 'random_mult', 'Randomize Clones' )
- local_tr = nuke.XYZ_Knob('local_translate', 'translate')
- local_rot = nuke.XYZ_Knob('local_rotate', 'rotate')
- local_scale = nuke.Scale_Knob('local_scaling', 'scale')
- local_size = nuke.Double_Knob('local_uniform_scale', 'uniform scale')
- local_size.setValue(1)
- local_skew = nuke.XYZ_Knob('local_skew', 'skew')
- g.addKnob( curr_num )
- g.addKnob( num_clones )
- g.addKnob( master_time_offset )
- g.addKnob( divider3 )
- g.addKnob( master_tr )
- g.addKnob( master_rot )
- g.addKnob( master_scale )
- g.addKnob( master_size )
- g.addKnob( master_skew )
- g.addKnob( divider4 )
- g.addKnob( local_tr )
- g.addKnob( local_rot )
- g.addKnob( local_scale )
- g.addKnob( local_size )
- g.addKnob( local_skew )
- g.knob('knobChanged').setValue(knobChangedCode)
- g.begin()
- i = nuke.nodes.Input(name = 'Geo')
- o = nuke.nodes.Output(name = 'Clones_Output')
- s = nuke.nodes.Scene(name = 'Clones_Scene')
- s.setInput(0,i)
- o.setInput(0,s)
- s.setXpos(i.xpos())
- s.setYpos(i.ypos()+500)
- o.setXpos(s.xpos())
- o.setYpos(s.ypos()+100)
- g.end()
- try:
- sel = nuke.selectedNode()
- g.setInput(0, sel)
- except:
- pass
Advertisement
Add Comment
Please, Sign In to add comment