def __init__(self, _object): # the object self._object = auxiliary.get_valid_dag_node(_object) assert (isinstance(self._object, pm.nodetypes.Transform)) # the data self._futurePivot = pm.nodetypes.Transform self._isSetup = False # read the settings self._read_settings()
def __init__(self, _object): # the object self._object = auxiliary.get_valid_dag_node(_object) assert isinstance(self._object, pm.nodetypes.Transform) # the data self._futurePivot = pm.nodetypes.Transform self._isSetup = False # read the settings self._read_settings()
def get_one_switcher(): """returns a generator that generates a PivotSwitcher object for every transform node in the selection """ for node in pm.ls(sl=True): try: node = auxiliary.get_valid_dag_node(node) if node.type() == "transform": my_pivot_switcher = PivotSwitcher(node) yield my_pivot_switcher except TypeError: pass
def get_one_switcher(): """returns a generator that generates a PivotSwitcher object for every transform node in the selection """ for node in pm.ls(sl=True): try: node = auxiliary.get_valid_dag_node(node) if node.type() == "transform": my_pivot_switcher = PivotSwitcher(node) yield my_pivot_switcher except TypeError: pass
def _read_settings(self): """reads the settings from the objects pivotData attribute """ # check if the object has pivotData attribute if self._object.hasAttr("pivotData"): # get the future pivot object self._futurePivot = auxiliary.get_valid_dag_node( pm.listConnections( self._object.attr("pivotData.futurePivot"))[0]) # set isSetup flag to True self._isSetup = True return True return False
def _read_settings(self): """reads the settings from the objects pivotData attribute """ # check if the object has pivotData attribute if self._object.hasAttr("pivotData"): # get the future pivot object self._futurePivot = auxiliary.get_valid_dag_node( pm.listConnections(self._object.attr("pivotData.futurePivot"))[0] ) # set isSetup flag to True self._isSetup = True return True return False
def _create_future_pivot(self): """creates the futurePivot locator """ if self._isSetup: return # create a locator and move it to the current pivot # parent the locator under the object locator_name = self._object.name() + "_futurePivotLocator#" self._futurePivot = \ auxiliary.get_valid_dag_node(pm.spaceLocator(n=locator_name)) pm.parent(self._futurePivot, self._object) current_pivot_pos = pm.xform(self._object, q=True, ws=True, piv=True) pm.xform(self._futurePivot, ws=True, t=current_pivot_pos[0:3]) # change the color self._futurePivot.setAttr("overrideEnabled", 1) self._futurePivot.setAttr("overrideColor", 13) # set translate and visibility to non-keyable self._futurePivot.setAttr("tx", k=False, channelBox=True) self._futurePivot.setAttr("ty", k=False, channelBox=True) self._futurePivot.setAttr("tz", k=False, channelBox=True) self._futurePivot.setAttr("v", k=False, channelBox=True) # lock scale and rotate self._futurePivot.setAttr("rx", lock=True, k=False, channelBox=False) self._futurePivot.setAttr("ry", lock=True, k=False, channelBox=False) self._futurePivot.setAttr("rz", lock=True, k=False, channelBox=False) self._futurePivot.setAttr("sx", lock=True, k=False, channelBox=False) self._futurePivot.setAttr("sy", lock=True, k=False, channelBox=False) self._futurePivot.setAttr("sz", lock=True, k=False, channelBox=False) # hide it self._futurePivot.setAttr("v", 0)
def _create_future_pivot(self): """creates the futurePivot locator """ if self._isSetup: return # create a locator and move it to the current pivot # parent the locator under the object locator_name = self._object.name() + "_futurePivotLocator#" self._futurePivot = auxiliary.get_valid_dag_node(pm.spaceLocator(n=locator_name)) pm.parent(self._futurePivot, self._object) current_pivot_pos = pm.xform(self._object, q=True, ws=True, piv=True) pm.xform(self._futurePivot, ws=True, t=current_pivot_pos[0:3]) # change the color self._futurePivot.setAttr("overrideEnabled", 1) self._futurePivot.setAttr("overrideColor", 13) # set translate and visibility to non-keyable self._futurePivot.setAttr("tx", k=False, channelBox=True) self._futurePivot.setAttr("ty", k=False, channelBox=True) self._futurePivot.setAttr("tz", k=False, channelBox=True) self._futurePivot.setAttr("v", k=False, channelBox=True) # lock scale and rotate self._futurePivot.setAttr("rx", lock=True, k=False, channelBox=False) self._futurePivot.setAttr("ry", lock=True, k=False, channelBox=False) self._futurePivot.setAttr("rz", lock=True, k=False, channelBox=False) self._futurePivot.setAttr("sx", lock=True, k=False, channelBox=False) self._futurePivot.setAttr("sy", lock=True, k=False, channelBox=False) self._futurePivot.setAttr("sz", lock=True, k=False, channelBox=False) # hide it self._futurePivot.setAttr("v", 0)