示例#1
0
 def requiredAttributes( self, *args, **kwargs ):
     '''
     kwargs
     curveType: Type of curve control to make. Square, triangle, arrow, plus, pyramid, circle, ringDirection.
     '''
     super( CurveControlComponent, self ).requiredAttributes()
     NodeUtility.addPlug( self.newNode, 'controlName', 'dataType', 'string' )
     NodeUtility.addPlug( self.newNode, 'curveType', 'dataType', 'string' )
     self.setAttribute( 'curveType', kwargs['curveType'], self.newNode )
     
     # Add attribute for control color.
     NodeUtility.addPlug( self.newNode, 'controlColor', 'attributeType', 'byte' )
     self.setAttribute( 'controlColor', 1, self.newNode )
     
     # Control transform relative to the parent.
     NodeUtility.addPlug( self.newNode, 'controlPosition', 'attributeType', 'float3' )
     NodeUtility.addPlug( self.newNode, 'controlRotation', 'attributeType', 'float3' )
     NodeUtility.addPlug( self.newNode, 'controlScale', 'attributeType', 'float3' )
     
     # Add attributes for the curve CVs.
     tempCurve = self.createCurveControl( '{0}TempCurve'.format( self.newNode ), kwargs['curveType'] )
     tempCurveName = OpenMaya.MDagPath.getAPathTo( tempCurve ).fullPathName()
     tempCurvePoints = NurbsCurveUtility.getCurveCvs( tempCurveName )
     NurbsCurveUtility.addCurveValues( self.newNode, tempCurvePoints )
     
     # Update curve transform values.
     storeControlTransforms( tempCurveName, self.newNode )
     
     # Clean up.
     cmds.delete( tempCurveName )
示例#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()