WrapNode = former(mainCurve, name="StickyLips_Wrap", type="wrap")Ĭmds.connectAttr(self.receptList+".dropoff", wrapNode+".dropoff", force=True)Ĭmds.connectAttr(self.receptList+".inflType", wrapNode+".inflType", force=True)Ĭmds.connectAttr(self.receptList+".smoothness", wrapNode+".smoothness", force=True)Ĭmds.connectAttr(self.receptList+"Shape.worldMesh", wrapNode+".driverPoints", force=True)Ĭmds.connectAttr(baseMesh+"Shape.worldMesh", wrapNode+".basePoints", force=True)Ĭmds.connectAttr(mainCurve+"Shape.worldMatrix", wrapNode+".geomMatrix", force=True)Ĭmds.setAttr(wrapNode+".autoWeightThreshold", 1)Ĭmds.setAttr(wrapNode+".exclusiveBind", 1)īaseCurveList = įor c, baseCurve in enumerate(baseCurveList): MainCurveList = īaseMesh = cmds.duplicate(self.receptList, name=self.receptList+"Base") Mc.parentConstraint( self.Def sqCreateStikyLipsDeformers(self, *args): def attachObject( self, huh): #Check that a target and constraint target have been specified if ( self.target = None ) | ( nstraintTarget = None ): #This method attaches the constraint target to the target using locators.
Maya python ls command dont list all duplicates code#
Mc.parentConstraint( self.target, targetLoc, maintainOffset = False )īut if I simply add another argument to the def attachObject method like below.the code works as expected. #Parent Constrain parent locator to target Mc.parentConstraint( targetManipLoc, nstraintTarget, maintainOffset = False ) #Parent Constrain constraint target to _MANIP locator with maintain offset OFF #Parent MANIP to constraint target locator TargetManipLoc = mc.spaceLocator( name = ( nstraintTargetName + "_MANIP" ) ) #Create locator named constraintTargetName + _MANIP TargetLoc = mc.spaceLocator( name = nstraintTargetName ) #Create locator named after constraint target Print "Make sure you have selected a *Target* and an *Object or Control to be Constrained*" print "self.target = " + self.target + "\n" print "nstraintTarget = " + nstraintTarget + "\n" else: def attachObject( self): #Check that a target and constraint target have been specified if ( self.target = None ) | ( nstraintTarget = None ): Mc.textFieldButtonGrp( nstraintTargetTextFieldButtonGrp, edit = True, text = nstraintTargetName ) #Update text field with name of constraint target #Make sure exactly ONE object is selected if len ( selectedObj ) != 1: #It also updates the object's textFieldButtonGrp to display the name of the current constraint target def updateConstraintTarget( self): #Get the name of the currently selected object #This method sets the currently selected object as the object to be constrained. Mc.textFieldButtonGrp( self.targetTextFieldButtonGrp, edit = True, text = selectedObj ) #Update text field with name of selected object Print "Select exactly ONE object or control!" else: #Check that only one object is selected if len( selectedObj ) != 1: def updateTarget( self): #Get name of selected object #Assign selected object to a variable to keep track of it
#It also updates the Target textFieldButtonGrp to display the name of the current target object. #This method sets the currently selected object as the target object.
Test = mc.button( label = "Attach Object", command = self.attachObject ) nstraintTargetTextFieldButtonGrp = mc.textFieldButtonGrp( buttonLabel = "Update", buttonCommand = partial( self.updateConstraintTarget ) )
Mc.text( "\nObject or Control to be Constrained:\n" ) Self.targetTextFieldButtonGrp = mc.textFieldButtonGrp( buttonLabel = "Update", buttonCommand = partial( self.updateTarget ) ) ObjAttachTool = mc.window( self.windowName, title = "Object Attachment Tool", sizeable = False, widthHeight = ( 1024, 750 ) ) nstraintTargetName = "" def buildUI( self): #Add code to check if Window already exists #Window is not re-sizeable Self.windowName = "Object Attachment Tool" #Class to hold UI methods class UI(): def _init_( self): "# Error: attachObject() takes exactly 1 argument (2 given) # " import maya.cmds as mc
If I run the following code I get the error msg: I've been working on a relatively simple tool that creates a simple UI that a user can use to constrain one object to another, but still have the freedom to move that object once its constrained. I'm really quite new to scripting in Maya.