def tweak_joint_orientation(self, mult, **kwargs): kwargs.update({'rotateAxis': kwargs.pop('ra', kwargs.pop('rotateAxis', Vector( \ self.tweakXDouble.value(), self.tweakYDouble.value(), self.tweakZDouble.value()) * mult))}) zso = self.zeroScaleOrientCB.isChecked() for j in self.get_affected_joints(): xform(j, objectSpace=True, relative=True, **kwargs) if zso: j.zeroScaleOrient() self.freeze(j)
def alignToCamera(self): if general.objExists("WaffleSliceGizmo"): cam = self.getCurrentCamera() if cam!='' and general.objExists(cam): general.xform("WaffleSliceGizmo", t=[general.getAttr(cam+".translateX"), general.getAttr(cam+".translateY"), general.getAttr(cam+".translateZ"),] , ro = [general.getAttr(cam+".rotateX"), general.getAttr(cam+".rotateY"), general.getAttr(cam+".rotateZ"),] ,ws = True) general.rotate("WaffleSliceGizmo", [0,90,0], os = True, r = True)
def __new__(cls, **kwargs): s = super(Custom, cls).__new__(cls, **kwargs) transforms = ls(selection=True, transforms=True) for t in transforms: shapes = t.getShapes() if shapes: s.extend(shapes) elif isinstance(t, nt.Joint): s.append(t) xform(t, translation=(0, 0, 0)) else: # Delete empty transforms. delete(t) s.extend([n for n in ls(selection=True, shapes=True) if n not in s]) return s
def performSlice(self): #Make sure theres a gizmo, otherwise theres no point in doing anything if general.objExists("WaffleSliceGizmo"): #Get the step size and step count from the appropriate sliders step_size = windows.floatSliderGrp("stepSizeSlider", q = True, v = True) step_count = int(windows.floatSliderGrp("stepCountSlider", q = True, v = True)) #Get the axes filter from the radio buttons axes = windows.radioButtonGrp("axesRadioButtonGrp", q = True, sl = True) #Iterate through the selected objects and create an array of sliceable ones sliceArray = [] for child in general.ls(sl = True): if (child!="WaffleSliceGizmo"): #Make sure the selection is either a transform or mesh if (general.objectType(child)=="transform" or general.objectType(child)=="mesh"): sliceArray.append(child) else: #If anything was added to the array, then move forwards with the waffle slice if len(sliceArray)>0: #Create the slicing proxies that will push the proper transforms and rotates into the slice arguments general.group(n = "slice_proxy_x", em = True) general.xform("slice_proxy_x", t=[general.getAttr("WaffleSliceGizmo.translateX"), general.getAttr("WaffleSliceGizmo.translateY"), general.getAttr("WaffleSliceGizmo.translateZ"),] , ro = [general.getAttr("WaffleSliceGizmo.rotateX"), general.getAttr("WaffleSliceGizmo.rotateY"), general.getAttr("WaffleSliceGizmo.rotateZ"),] ,ws = True) general.group(n = "slice_proxy_y", em = True) general.xform("slice_proxy_y", t=[general.getAttr("WaffleSliceGizmo.translateX"), general.getAttr("WaffleSliceGizmo.translateY"), general.getAttr("WaffleSliceGizmo.translateZ"),] , ro = [general.getAttr("WaffleSliceGizmo.rotateX"), general.getAttr("WaffleSliceGizmo.rotateY"), general.getAttr("WaffleSliceGizmo.rotateZ"),] ,ws = True) general.rotate("slice_proxy_y", (90, 0, 0), r = True, os = True) general.parent("slice_proxy_x", "WaffleSliceGizmo") general.parent("slice_proxy_y", "WaffleSliceGizmo") #Iterate through the list of objects for child in sliceArray: #Move the slicers by half of the total distance they're going to need to slice through general.move("slice_proxy_x", [0,0,(-1*((step_size*step_count)/2))] , r = True, ls = True)#, z = True) general.move("slice_proxy_y", [0, (-1*((step_size*step_count)/2)),0], r = True, ls = True)#, y = True) #Get the options for x, y, or both #Do the slices, and for each iteration, bump each proxy forwards by their allotted amount for i in range(step_count): if (axes == 1 or axes == 3): general.move("slice_proxy_x", [0, 0, step_size] , r = True, ls = True)#, z = True) pos = general.xform("slice_proxy_x", ws = True, q = True, t = True) rot = general.xform("slice_proxy_x", ws = True, q = True, ro = True) modeling.polyCut(child, ro = rot , pc = pos) general.delete(child, ch = True) if (axes == 2 or axes == 3): general.move("slice_proxy_y", [0, step_size, 0], r = True, ls = True)#, y = True) pos = general.xform("slice_proxy_y", ws = True, q = True, t = True) rot = general.xform("slice_proxy_y", ws = True, q = True, ro = True) modeling.polyCut(child, ro = rot , pc = pos) general.delete(child, ch = True) else: #Reset the position of the proxies after each object so they dont fly off into the distance general.xform("slice_proxy_x", t=[general.getAttr("WaffleSliceGizmo.translateX"), general.getAttr("WaffleSliceGizmo.translateY"), general.getAttr("WaffleSliceGizmo.translateZ"),] , ws = True) general.xform("slice_proxy_y", t=[general.getAttr("WaffleSliceGizmo.translateX"), general.getAttr("WaffleSliceGizmo.translateY"), general.getAttr("WaffleSliceGizmo.translateZ"),] , ws = True) else: #Clean up the slice proxies general.delete("slice_proxy_x") general.delete("slice_proxy_y") else: print("No slice gizmo")