cwisbg

Nudger v_Camera Refiner

Nov 17th, 2012
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.84 KB | None | 0 0
  1. # Nudger v_Camera Refiner
  2. # cwisbg
  3. from pymel.core import *
  4. def nudger(direction):
  5.     s = selected()[0]
  6.     sl = selected()
  7.     amt = nudgeAmnt.getText()
  8.     amt = float(amt)
  9.     if len(sl) == 0:
  10.         print "nothin to nudge"
  11.     else:
  12.         if tbox.getValue():
  13.             if direction == "X+":
  14.                 move(s,amt,0,0,r=1)
  15.             elif direction == "X-":
  16.                 move(s,-amt,0,0,r=1)
  17.             elif direction == "Y+":
  18.                 move(s,0,amt,0,r=1)
  19.             elif direction == "Y-":
  20.                 move(s,0,-amt,0,r=1)            
  21.             elif direction == "Z+":
  22.                 move(s,0,0,amt,r=1)  
  23.             elif direction == "Z-":
  24.                 move(s,0,0,-amt,r=1)
  25.         if rbox.getValue():
  26.             if direction == "X+":
  27.                 rotate(s,amt,0,0,r=1, os=1)
  28.             elif direction == "X-":
  29.                 rotate(s,-amt,0,0,r=1, os=1)
  30.             elif direction == "Y+":
  31.                 rotate(s,0,amt,0,r=1, os=1)
  32.             elif direction == "Y-":
  33.                 rotate(s,0,-amt,0,r=1, os=1)            
  34.             elif direction == "Z+":
  35.                 rotate(s,0,0,amt,r=1, os=1)  
  36.             elif direction == "Z-":
  37.                 rotate(s,0,0,-amt,r=1, os=1)
  38.         if wrbox.getValue():
  39.             if direction == "X+":
  40.                 rotate(s,amt,0,0,r=1, ws=1)
  41.             elif direction == "X-":
  42.                 rotate(s,-amt,0,0,r=1, ws=1)
  43.             elif direction == "Y+":
  44.                 rotate(s,0,amt,0,r=1, ws=1)
  45.             elif direction == "Y-":
  46.                 rotate(s,0,-amt,0,r=1, ws=1)            
  47.             elif direction == "Z+":
  48.                 rotate(s,0,0,amt,r=1, ws=1)  
  49.             elif direction == "Z-":
  50.                 rotate(s,0,0,-amt,r=1, ws=1)
  51.         if dpbox.getValue():
  52.             if direction == "X+":
  53.                 move(s,amt,0,0,r=1, os=1)
  54.             elif direction == "X-":
  55.                 move(s,-amt,0,0,r=1, os=1)
  56.             elif direction == "Y+":
  57.                 move(s,0,amt,0,r=1, os=1)
  58.             elif direction == "Y-":
  59.                 move(s,0,-amt,0,r=1, os=1)            
  60.             elif direction == "Z+":
  61.                 move(s,0,0,amt,r=1, os=1)  
  62.             elif direction == "Z-":
  63.                 move(s,0,0,-amt,r=1, os=1)                
  64.         else:
  65.             pass
  66. def zoomAjst():
  67.     cam = selected()
  68.     if len(cam) == 0:
  69.         print "Please select a camera"
  70.     else:
  71.         camCheck = nodeType(cam[0],api=1)
  72.         if camCheck:
  73.             zoomAmnt = zoomSlider.getValue()
  74.             setAttr(cam[0]+"Shape.zoom", zoomAmnt)
  75.         else:
  76.             print "Please select a camera"
  77.    
  78. def zoomAjst1():
  79.     cam = selected()[0]
  80.     zX = zoomXSlider.getValue()
  81.     panX = setAttr(cam+"Shape.horizontalPan", zX)
  82.     zY = zoomYSlider.getValue()
  83.     panY = setAttr(cam+"Shape.verticalPan", zY)
  84.    
  85. def reseter():    
  86.     cam = selected()[0]
  87.     zoomEnbl.setValue(0)
  88.     zoomSlider.setValue(1)
  89.     zoomXSlider.setValue(0)
  90.     zoomYSlider.setValue(0)
  91.     setAttr(cam+"Shape.horizontalPan", 0)
  92.     setAttr(cam+"Shape.verticalPan", 0)
  93.     setAttr(cam+"Shape.panZoomEnabled", 0)
  94.     setAttr(cam+"Shape.zoom", 1)
  95.    
  96. def enableZoom():
  97.     if len(selected()) == 0:
  98.         print "nothing selected"
  99.     else:
  100.         cam = selected()[0]
  101.         if zoomEnbl.getValue():
  102.             setAttr(cam+"Shape.panZoomEnabled", 1)
  103.         else:
  104.             zoomEnbl.setValue(0)
  105.             setAttr(cam+"Shape.panZoomEnabled", 0)
  106.  
  107. win = window(title="My Window")
  108. layout = columnLayout(bgc = [.3,.3,.3],)
  109. text(l="Nudge Amnt")
  110. nudgeAmnt = textField(w=70,tx = ".1" )
  111.  
  112. tbox = checkBox(l = "Translate")
  113. rbox = checkBox(l = "Rotate" , v=1)
  114. wrbox = checkBox(l = "World Rotate")
  115. dpbox = checkBox(l = "Dolly/Pan" )
  116.  
  117. btnLayout = rowColumnLayout(nc=2,rs=(1,10),cs=(2,10))
  118. x0 = button(l="X-",command=Callback(nudger,"X-"), parent = btnLayout)
  119. x = button(l="X+",command=Callback(nudger,"X+"), parent = btnLayout)
  120. y0 = button(l="Y-",command=Callback(nudger,"Y-"), parent = btnLayout)
  121. y = button(l="Y+",command=Callback(nudger,"Y+"), parent = btnLayout)
  122. z0 = button(l="Z-",command=Callback(nudger,"Z-"), parent = btnLayout)
  123. z = button(l="Z+",command=Callback(nudger,"Z+"), parent = btnLayout)
  124.  
  125. zoomEnbl = checkBox(l = "Enable Zoom",onc=Callback(enableZoom),ofc=Callback(enableZoom), p = layout)
  126. text(l="Zoom Amount", p=layout)
  127. zoomSlider = floatSlider(dc=Callback(zoomAjst),min = 0.01, max = 1, p= layout)
  128. zoomSlider.setValue(1)
  129. text(l="Pan X", p= layout)
  130. zoomXSlider = floatSlider(dc=Callback(zoomAjst1),min = -1, max = 1, p= layout)
  131. zoomXSlider.setValue(0)
  132. text(l="Pan Y", p= layout)
  133. zoomYSlider = floatSlider(dc=Callback(zoomAjst1),min = -1, max = 1, p= layout)
  134. zoomYSlider.setValue(0)
  135. resetButton = button(l = "Reset Zoom",command=Callback(reseter), parent = layout)
  136.  
  137. win.show()
Advertisement
Add Comment
Please, Sign In to add comment