def addHelix(self, HNumber): m = Mom() h = self.helix() h.id = HNumber h.helixTransform = m.getNodeFromName( "%s%s" % (m.helixTransformName, HNumber)) h.helixNode = m.getNodeFromName("%s%s" % (m.helixNodeName, HNumber)) nodeFn = OpenMaya.MFnDependencyNode(h.helixNode) h.helixName = nodeFn.name() self.helices[h.id] = h self.helicesNames.append(h.helixName) # we only connect the first node, so that the update events trigger # the delta value will be the same for all the helices if(len(self.helices) == 1): self.firstHelix = h.id self.connectToDependNode(h)
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 addHelix(self, HNumber): m = Mom() h = self.helix() h.id = HNumber h.helixTransform = m.getNodeFromName( "%s%s" % (m.helixTransformName, HNumber)) h.helixNode = m.getNodeFromName("%s%s" % (m.helixNodeName, HNumber)) nodeFn = OpenMaya.MFnDependencyNode(h.helixNode) h.helixName = nodeFn.name() self.helices[h.id] = h self.helicesNames.append(h.helixName) # we only connect the first node, so that the update events trigger # the delta value will be the same for all the helices if(len(self.helices) == 1): self.firstHelix = h.id self.connectToDependNode(h)