Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Nudger v_Camera Refiner
- # cwisbg
- from pymel.core import *
- def nudger(direction):
- s = selected()[0]
- sl = selected()
- amt = nudgeAmnt.getText()
- amt = float(amt)
- if len(sl) == 0:
- print "nothin to nudge"
- else:
- if tbox.getValue():
- if direction == "X+":
- move(s,amt,0,0,r=1)
- elif direction == "X-":
- move(s,-amt,0,0,r=1)
- elif direction == "Y+":
- move(s,0,amt,0,r=1)
- elif direction == "Y-":
- move(s,0,-amt,0,r=1)
- elif direction == "Z+":
- move(s,0,0,amt,r=1)
- elif direction == "Z-":
- move(s,0,0,-amt,r=1)
- if rbox.getValue():
- if direction == "X+":
- rotate(s,amt,0,0,r=1, os=1)
- elif direction == "X-":
- rotate(s,-amt,0,0,r=1, os=1)
- elif direction == "Y+":
- rotate(s,0,amt,0,r=1, os=1)
- elif direction == "Y-":
- rotate(s,0,-amt,0,r=1, os=1)
- elif direction == "Z+":
- rotate(s,0,0,amt,r=1, os=1)
- elif direction == "Z-":
- rotate(s,0,0,-amt,r=1, os=1)
- if wrbox.getValue():
- if direction == "X+":
- rotate(s,amt,0,0,r=1, ws=1)
- elif direction == "X-":
- rotate(s,-amt,0,0,r=1, ws=1)
- elif direction == "Y+":
- rotate(s,0,amt,0,r=1, ws=1)
- elif direction == "Y-":
- rotate(s,0,-amt,0,r=1, ws=1)
- elif direction == "Z+":
- rotate(s,0,0,amt,r=1, ws=1)
- elif direction == "Z-":
- rotate(s,0,0,-amt,r=1, ws=1)
- if dpbox.getValue():
- if direction == "X+":
- move(s,amt,0,0,r=1, os=1)
- elif direction == "X-":
- move(s,-amt,0,0,r=1, os=1)
- elif direction == "Y+":
- move(s,0,amt,0,r=1, os=1)
- elif direction == "Y-":
- move(s,0,-amt,0,r=1, os=1)
- elif direction == "Z+":
- move(s,0,0,amt,r=1, os=1)
- elif direction == "Z-":
- move(s,0,0,-amt,r=1, os=1)
- else:
- pass
- def zoomAjst():
- cam = selected()
- if len(cam) == 0:
- print "Please select a camera"
- else:
- camCheck = nodeType(cam[0],api=1)
- if camCheck:
- zoomAmnt = zoomSlider.getValue()
- setAttr(cam[0]+"Shape.zoom", zoomAmnt)
- else:
- print "Please select a camera"
- def zoomAjst1():
- cam = selected()[0]
- zX = zoomXSlider.getValue()
- panX = setAttr(cam+"Shape.horizontalPan", zX)
- zY = zoomYSlider.getValue()
- panY = setAttr(cam+"Shape.verticalPan", zY)
- def reseter():
- cam = selected()[0]
- zoomEnbl.setValue(0)
- zoomSlider.setValue(1)
- zoomXSlider.setValue(0)
- zoomYSlider.setValue(0)
- setAttr(cam+"Shape.horizontalPan", 0)
- setAttr(cam+"Shape.verticalPan", 0)
- setAttr(cam+"Shape.panZoomEnabled", 0)
- setAttr(cam+"Shape.zoom", 1)
- def enableZoom():
- if len(selected()) == 0:
- print "nothing selected"
- else:
- cam = selected()[0]
- if zoomEnbl.getValue():
- setAttr(cam+"Shape.panZoomEnabled", 1)
- else:
- zoomEnbl.setValue(0)
- setAttr(cam+"Shape.panZoomEnabled", 0)
- win = window(title="My Window")
- layout = columnLayout(bgc = [.3,.3,.3],)
- text(l="Nudge Amnt")
- nudgeAmnt = textField(w=70,tx = ".1" )
- tbox = checkBox(l = "Translate")
- rbox = checkBox(l = "Rotate" , v=1)
- wrbox = checkBox(l = "World Rotate")
- dpbox = checkBox(l = "Dolly/Pan" )
- btnLayout = rowColumnLayout(nc=2,rs=(1,10),cs=(2,10))
- x0 = button(l="X-",command=Callback(nudger,"X-"), parent = btnLayout)
- x = button(l="X+",command=Callback(nudger,"X+"), parent = btnLayout)
- y0 = button(l="Y-",command=Callback(nudger,"Y-"), parent = btnLayout)
- y = button(l="Y+",command=Callback(nudger,"Y+"), parent = btnLayout)
- z0 = button(l="Z-",command=Callback(nudger,"Z-"), parent = btnLayout)
- z = button(l="Z+",command=Callback(nudger,"Z+"), parent = btnLayout)
- zoomEnbl = checkBox(l = "Enable Zoom",onc=Callback(enableZoom),ofc=Callback(enableZoom), p = layout)
- text(l="Zoom Amount", p=layout)
- zoomSlider = floatSlider(dc=Callback(zoomAjst),min = 0.01, max = 1, p= layout)
- zoomSlider.setValue(1)
- text(l="Pan X", p= layout)
- zoomXSlider = floatSlider(dc=Callback(zoomAjst1),min = -1, max = 1, p= layout)
- zoomXSlider.setValue(0)
- text(l="Pan Y", p= layout)
- zoomYSlider = floatSlider(dc=Callback(zoomAjst1),min = -1, max = 1, p= layout)
- zoomYSlider.setValue(0)
- resetButton = button(l = "Reset Zoom",command=Callback(reseter), parent = layout)
- win.show()
Advertisement
Add Comment
Please, Sign In to add comment