Hey,
I’m currently working on a rigging script that in the end will be able to create a joint chain based on values that the user can enter via sliders.
I’m having some trouble getting the values from the sliders into the function that creates the initial joint setup.
My code is below. What I want to do is to grab the values of the sliders and chuck them into the functions rbLegGhostJoints and rbArmGhostJoints, so that I can use those values when creating the “ghost” joints(e g spheres or some such). I don’t have much experience with Python to be honest, or not as much I’d like, and I’m having some trouble figuring out callbacks and whether or not I should use a class for this, and a bunch of other stuff I’m trying to learn.
import pymel.core as pm
def rbLegGhostJoints(*args):
pass
def rbArmGhostJoints(*args):
pass
def rbLegJoints(*args):
pass
def rbArmJoints(*args):
pass
def rbRiggingUI():
if pm.window( "rbRiggingWindow", exists = True ):
pm.deleteUI( "rbRiggingWindow" )
pm.window( "rbRiggingWindow", title = "RB Rigging", resizeToFitChildren = True )
tabControls = pm.tabLayout()
legLayout = pm.columnLayout()
legLengthText = pm.text( label = "Enter leg start length:" )
legLength = pm.textField()
legJointsText = pm.text( label = "Number of leg joints:" )
numberOfLegJoints = pm.intSliderGrp( "numberOfLegJoints", minValue = 3, maxValue = 20, step = 1, field = True )
legUpperTwistsText = pm.text( label = "Number of upper leg twist joints:" )
numberOfUpperLegTwists = pm.intSliderGrp( "numberOfUpperLegTwists", minValue = 0, maxValue = 10, step = 1, field = True )
legLowerTwistsText = pm.text( label = "Number of lower leg twist joints:" )
numberOfLowerLegTwists = pm.intSliderGrp( "numberOfLowerLegTwists", minValue = 0, maxValue = 10, step = 1, field = True)
createLegGhostJoints = pm.button( label = "Create ghost joints", command = rbLegGhostJoints )
pm.separator( height = 20, width = 300)
createLegJoints = pm.button( label = "Create joints", command = rbLegJoints )
pm.setParent('..')
armLayout = pm.columnLayout()
armLengthText = pm.text( label = "Enter arm start length:" )
armLength = pm.textField()
armJointsText = pm.text( label = "Number of arm joints:" )
numberOfArmJoints = pm.intSliderGrp( "numberOfArmJoints", minValue = 3, maxValue = 20, step = 1, field = True )
armUpperTwistsText = pm.text( label = "Number of upper arm twist joints:" )
numberOfUpperArmTwists = pm.intSliderGrp( "numberOfUpperArmTwists", minValue = 0, maxValue = 10, step = 1, field = True )
armLowerTwistsText = pm.text( label = "Number of lower arm twist joints:" )
numberOfLowerArmTwists = pm.intSliderGrp( "numberOfLowerArmTwists", minValue = 0, maxValue = 10, step = 1, field = True )
createArmGhostJoints = pm.button( label = "Create ghost joints", command = rbArmGhostJoints )
pm.separator( height = 20, width = 300)
createArmJoints = pm.button( label = "Create joints", command = rbArmJoints )
pm.setParent('..')
pm.tabLayout( tabControls, edit = True, tabLabel=(( legLayout, "Legs" ),( armLayout, "Arms" )) )
pm.showWindow( "rbRiggingWindow" )
rbRiggingUI()