Example #1
0
 def buildNode( cls, nodeName ):
     '''
     Builds a curve control.
     
     @param nodeName: String. Name of the node.
     '''        
     # Create the curve.
     curveNode = CurveControlComponent( nodeName ).createCurveControl( cls( nodeName ).controlName, cls( nodeName ).curveType )
     controlName = OpenMaya.MDagPath.getAPathTo( curveNode ).fullPathName()
     
     # Set the control to the transform matrix.
     applyStoredTransforms( nodeName, controlName )
     
     # Get the saved properties and apply them to the curve.
     cvList = NurbsCurveUtility.readCurveValues( nodeName )
     cvPointArray = NurbsCurveUtility.buildCVPointArray( cvList )
     NurbsCurveUtility.setCurveCvs( controlName, cvPointArray )
     
     # Color.
     GeneralUtility.setUserColor( controlName, userColor=cls( nodeName ).controlColor )
     
     # Create the control spacer.
     transReference = NodeUtility.getNodeAttrSource( nodeName, 'parentName' )
     controlSpacer = GeneralUtility.createSpacer( None, inGroupName=cls( nodeName ).controlName, inTargetObject=transReference[0], inDoParent=False, inPrefix='sp' )
     cmds.parent( controlName, controlSpacer, relative=True )
     return curveNode
Example #2
0
    def editCurveProperties( self ):
        '''
        Activates the control so the user can edit it's properties.
        '''
        if self.editButton.isChecked():
            if self.textBox.text():
                # Lock the components UI.
                if self.parent.selectedLockActive is False:
                    self.parent.lockSelection()
                
                # Create the curve.
                curveType = CurveControlComponent( self.componentLabel.text() ).curveType
                node = CurveControlComponent( self.componentLabel.text() ).createCurveControl( self.textBox.text(), curveType )
                controlName = OpenMaya.MDagPath.getAPathTo( node ).fullPathName()
                
                # Parent the control to the bit.
                parentNode = CurveControlComponent( self.componentLabel.text() ).parentNode[0]
                cmds.parent( controlName, parentNode )
                self.CONTROL = OpenMaya.MDagPath.getAPathTo( node ).fullPathName()
                
                # Set the control to the transform matrix.
                applyStoredTransforms( self.componentLabel.text(), self.CONTROL )
                
                # Get the saved properties and apply them to the curve.
                cvList = NurbsCurveUtility.readCurveValues( self.componentLabel.text() )
                cvPointArray = NurbsCurveUtility.buildCVPointArray( cvList )
                NurbsCurveUtility.setCurveCvs( self.CONTROL, cvPointArray )
                
                # Color.
                GeneralUtility.setUserColor( self.CONTROL, userColor=self.COLOR )
            else:
                raise ValueError( '{0} does not have a Control Name set.'.format( self.componentLabel.text() ) )
        else:
            if self.CONTROL is not None:
                # Read the control properties and save them to the component node.
                cvList = NurbsCurveUtility.getCurveCvs( self.CONTROL )
                NurbsCurveUtility.writeCurveValues( self.componentLabel.text(), cvList )
                
                # Update the transform matrix.
                storeControlTransforms( self.CONTROL, self.componentLabel.text() )

                # Delete the control
                cmds.delete( self.CONTROL )
                self.CONTROL = None
                
            # Unlock the UI.
            if self.parent.selectedLockActive:
                self.parent.lockSelection()