def on_bufferButton_clicked(self): undoInfo(openChunk=True) for j in self.get_affected_joints(): buf = group(empty=True, world=True, name='BUF_' + j.nodeName()) p = j.getParent(1) if p: parent(buf, p) dupe = duplicate(j, renameChildren=True, returnRootsOnly=True)[0] snap(dupe, buf, space='object') delete(dupe) parent(j, buf) undoInfo(closeChunk=True)
def insert_bind_joints(self, cls, amount): inserted_joints = [] for bj in self.bind_joints[cls]: nj = bj.getChildren()[0] # next joint d = nj.attr('t').get() / (amount + 1) parent(nj, world=True) ij = bj for i in range(amount): ns = ij.name_sequence + 1 ij = ls(insertJoint(ij))[0] ij.attr('t').set(d) ij.__class__ = cls ij.name_sequence = ns self.name_helper.rename(ij, jt=bj.jtype, s=bj.side, ss=bj.side_sequence, n=bj.__name__, ns=ns) inserted_joints.append(ij) parent(nj, ij) self.set_bone_radii(bj) self.bind_joints[cls].extend(inserted_joints)
def __init__(self, **kwargs): """ Merge all shape nodes under a single transform and trash any left-over (empty) transforms. """ shapes = [n for n in self if not isinstance(n, nt.Joint)] empty_transforms = [s.getParent() for s in shapes if not \ [sib for sib in s.getSiblings() if sib not in self]] self._transform = nt.Transform() parent(self, self._transform, relative=True, shape=True) #if empty_transforms: # print('empty transforms:', empty_transforms) # delete(empty_transforms) select(self) DeleteHistory() snap_to = kwargs.pop('st', kwargs.pop('snap_to', None)) if snap_to: snap(self._transform, snap_to)
def createGizmo(self): ##All this needs to do is create a control square comprised of one transform and a bunch of shape objects parented to it. #First check to see if a gizmo exists that maybe got messed up or something. Delete that and recreate it if general.objExists("WaffleSliceGizmo"): general.delete("WaffleSliceGizmo") general.group(n = "WaffleSliceGizmo", em = True) _deleteArray = [] _shapesArray = [] _c = [] _c.append(modeling.nurbsSquare(n = "gizmoSquare1", nr = [0,0,1] ,c = [0, 0, 0], sl1 = 50, sl2 = 100)) _c.append(modeling.nurbsSquare(n = "gizmoSquare2", nr = [0,1,0] ,c = [0, 0, 0], sl1 = 100, sl2 = 50)) [general.parent(child, "WaffleSliceGizmo", r = True) for child in _c] for child in general.listRelatives("WaffleSliceGizmo", ad = True): if general.objectType(child)=="nurbsCurve": general.parent(child, "WaffleSliceGizmo", r = True, s = True) else: [general.delete(child) for child in general.listRelatives("WaffleSliceGizmo", type = "transform")] #WaffleSliceGizmo is the group that is created. Iterate through it, find a useable transform, get all the shapes, and assign #All the shapes to a transform general.delete("WaffleSliceGizmo", ch = True) general.select("WaffleSliceGizmo")
def __init__(self, *args, **kwargs): p = self.getParent() parent(self, world=True) self.orientJoint('none') parent(self, p) super(Collar, self).__init__({1: [Shoulder]}, *args, **kwargs)
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")
def __init__(self, *args, **kwargs): p = self.getParent() parent(self, world=True) self.orientJoint('none') parent(self, p) super(Collar, self).__init__({1:[Shoulder]}, *args, **kwargs)