def doPress(self): # print "PRESS" self.isMouseDown = True am = self.activeManip() m = Mom() m.strandsSelected( self.helicesNames, (am is self.fDistanceFrontManip, am is self.fDistanceBackManip)) self.createHelixDragMarker() selectedItems = cmds.ls(Mom().helixTransformName + "*", selection=True) bbox = cmds.exactWorldBoundingBox(selectedItems) cmds.setAttr(helixManip.transformName + ".scale", bbox[3] - bbox[0], 0, bbox[4] - bbox[1], type="double3") z = 0 if am is self.fDistanceFrontManip: z = bbox[5] elif am is self.fDistanceBackManip: z = bbox[2] self.moveHelixDragMarkerTo( ((bbox[0] + bbox[3]) / 2, (bbox[1] + bbox[4]) / 2, z)) cmds.showHidden(helixManip.transformName) self.calculateDeltaBounds() return OpenMaya.kUnknownParameter
def selectionCallback(clientData): """ Callback function that is called when the selection changes in Maya. """ clientData.deleteManipulators() #print "mayaSelcectionContex: selectionCallback called" selectionList = OpenMaya.MSelectionList() OpenMaya.MGlobal.getActiveSelectionList(selectionList) selectionIter = OpenMaya.MItSelectionList(selectionList) decoratorList = [] helixList = [] m = Mom() manipulator = None manipObject = OpenMaya.MObject() while not selectionIter.isDone(): transformNode = OpenMaya.MObject() dagNode = OpenMaya.MFnDagNode() try: selectionIter.getDependNode(transformNode) if transformNode.isNull() or not transformNode.hasFn( \ OpenMaya.MFn.kDependencyNode): selectionIter.next() continue dagNode = OpenMaya.MFnDagNode(transformNode) except: selectionIter.next() continue if dagNode.name().startswith(m.decoratorTransformName): if dagNode.name() not in decoratorList: decoratorList.append(dagNode.name()) elif dagNode.name().startswith(m.helixTransformName): Unused, HNumber = dagNode.name().split("_") helixName = "%s%s" % (m.helixNodeName, HNumber) helixNode = m.getNodeFromName(helixName) if helixNode: helixList.append(helixName) if manipulator is None: manipulator = \ OpenMayaMPx.MPxManipContainer.newManipulator( "spHelixManip", manipObject) if manipulator is not None: clientData.addManipulator(manipObject) manipulator.addHelix(HNumber) #print "selectionCallback ", dagNode.name(), helixNode selectionIter.next() m.staplePreDecoratorSelected(decoratorList) if manipulator is not None: manipulator.finishedAddingHelices() m.strandsSelected(helixList) m.updateSelectionBoxes()
def doRelease(self): # print "RELEASED" self.isMouseDown = False if(self.deltaFront != 0): app().activeDocument.document().resizeSelection(self.deltaFront) if(self.deltaBack != 0): app().activeDocument.document().resizeSelection(self.deltaBack) m = Mom() m.strandsSelected(self.helicesNames, (True, True)) cmds.hide(helixManip.transformName) self.frontDistance = 0 self.backDistance = 0 return OpenMaya.kUnknownParameter
def doPress(self): # print "PRESS" self.isMouseDown = True am = self.activeManip() m = Mom() m.strandsSelected( self.helicesNames, (am is self.fDistanceFrontManip, am is self.fDistanceBackManip) ) self.createHelixDragMarker() selectedItems = cmds.ls(Mom().helixTransformName + "*", selection=True) bbox = cmds.exactWorldBoundingBox(selectedItems) cmds.setAttr( helixManip.transformName + ".scale", bbox[3] - bbox[0], 0, bbox[4] - bbox[1], type="double3") z = 0 if am is self.fDistanceFrontManip: z = bbox[5] elif am is self.fDistanceBackManip: z = bbox[2] self.moveHelixDragMarkerTo(( (bbox[0] + bbox[3]) / 2, (bbox[1] + bbox[4]) / 2, z )) cmds.showHidden(helixManip.transformName) self.calculateDeltaBounds() return OpenMaya.kUnknownParameter