Beispiel #1
0
def text():
    t = pm.textField(tx, q=True, tx=True)
    
    pm.textCurves(t=t, ch=True)
    objs = pm.listRelatives(ad=True, typ='transform')
    for obj in objs:
        if "Char_" in obj.name():
            objs.remove(obj)
    pm.parent(objs, "Text_*")
    pm.makeIdentity(objs, a=True, t=1, r=1, s=1, n=0, pn=1)
    cmds.ResetTransformations(pm.ls(objs))
    pm.delete(objs, ch=True)
    pm.parent(pm.listRelatives(objs, ad=True), "Text_*", r=True, s=True)
    pm.delete("Char_*", objs)
    pm.ls("Text_*")[0].rename(t+"_crv")
Beispiel #2
0
def maketext(t=u"temptext",name = u"temptext", p=[0,0,0], r=[0,0,0], s=0.1) :
    t = str(t)
    obj = pm.textCurves(n = name, t=t, f ='Courier')
    pm.move(obj[0], p[0],p[1],p[2])
    pm.rotate(obj[0],r[0],r[1],r[2])
    pm.scale(obj[0],s,s,s)
    return obj[0]
Beispiel #3
0
def rig_makeCtrlLabel(label):
	'''Creates a control that is displayed in customized choice of letters
	Args:
		label (string): the name of the desired control/visual display text
	Returns (pm.nt.Transform): returns the display control object
	Example Usage:
		rig_makeCtrlLabel("display")
	'''
	if not pm.objExists(label + "_CTRL"):
		txt_crv=pm.PyNode( pm.textCurves(ch=0,t=label,f="Courier")[0] )
		curves=[]
		i=1
		for crvShp in pm.ls(txt_crv.getChildren(ad=True), et="nurbsCurve"):
			crvTrm = crvShp.getParent()
			crvShp.getParent().setParent(w=True)
			pm.makeIdentity(crvShp.getParent(),apply=True,s=1,r=1,t=1,n=0)
			crvTrm.rename("display_%02d_CRV" % i)
			curves.append(crvTrm)
			i+=1
		displayCtrl=rig_combineCurves(curves,label+'_CTRL')
		pm.delete(txt_crv)
		displayCtrl.centerPivots()
		pm.move(displayCtrl, (0,0,0), rpr=True)
		pm.makeIdentity(displayCtrl,apply=True,s=1,r=1,t=1,n=0)
		displayGrp=pm.group(em=1,n=(label + "Offset_GRP"))
		displayCtrl.setParent(displayGrp)
		for displayCtrlShape in displayCtrl.listRelatives(shapes=True, fullPath=True):
			pm.setAttr(displayCtrlShape + ".overrideEnabled", 1)
			pm.setAttr(displayCtrlShape + ".overrideColor",17)
			
		rig_ctrlLock([displayCtrl], ["tx","ty","tz","rx","ry","rz","sx","sy","sz","v"], setKeyable=False, lock=True)
		return displayCtrl
	else:
		pm.error("That control already exists smarty pants!\n")
    def _create_label(self):
        labels = pm.textCurves(ch=0, f="Arial", t=self.label, name="TEMP")
        label = pm.duplicate(labels[0])[0]
        pm.delete(labels)
        label.scale.set([self.label_scale, self.label_scale, self.label_scale])
        pm.makeIdentity(label, apply=True, t=True)

        shapes = label.listRelatives(ad=True, s=True)
        for shape in shapes:
            shape.rename("%s_%s" % (self.prefix, shape.name()))
        pm.parent(shapes, label, shape=True, relative=True)
        label.centerPivots()
        label.rename("Text_%s" % self.prefix)
        label.overrideEnabled.set(1)
        self.control_group.display >> label.overrideDisplayType
        self.control_group.display >> label.visibility
        pm.delete(label.listRelatives(ad=True, type="transform"))

        temp_loc = pm.spaceLocator()
        temp_loc.tx.set(self.label_offset[0])
        temp_loc.ty.set(self.label_offset[1])

        pm.delete(pm.pointConstraint(temp_loc, label, maintainOffset=False))
        pm.delete(temp_loc)

        pm.parent(label, self.control_group, absolute=True)
Beispiel #5
0
def measureExpression():
    '''
    /// exp
    measureRefPython:distanceDimension1.visibility=1;
    python("import measureUtils as mu"); 
    python("reload(mu)");
    python("mu.createMeasure()");
    '''
    sel = pm.selected()
    name = "distanceDimension1_annotation"

    if pm.objExists('measuregroup'):
        print 'exists'
        pm.delete('measuregroup')
    pm.group(n='measuregroup', empty=1)

    pm.setAttr('distanceDimension1.distanceFeet',
               pm.getAttr('distanceDimensionShape1.distance') * 0.0328084)
    t = pm.textCurves(ch=0,
                      f="Utopia-Regular",
                      n=name,
                      t=pm.getAttr('distanceDimension1.distanceFeet'))
    pm.parent(t, 'measuregroup')

    pm.select(sel)
def add_text_shape(ctrl, text):
    text_curve = pm.PyNode( pm.textCurves(ch=False, font="Arial Black", text=text, name='text_curve')[0] )
    text_curve_length = text_curve.boundingBox()[1][0] #max X
    text_curve_height = text_curve.boundingBox()[1][1] #max Y
    
    shapes = pm.listRelatives(text_curve, ad=True, type="shape")
    
    pm.xform(text_curve, piv=[0,text_curve_height,0], ws=True)

    pm.move(text_curve, 0, -text_curve_height , 0)

    scale = 1 / text_curve_length
    pm.scale(text_curve, scale, scale, scale)
            
    pm.makeIdentity(text_curve, apply=True, t=True, r=True, s=True)

    display_attr = ("%s_text_display"%text)
    if not ctrl.hasAttr(display_attr):
        ctrl.addAttr(display_attr, at='bool', k=True, dv=1)

    for s in shapes:
        pm.parent(s, ctrl, s=True, r=True)
        s.rename('%sText'%text)
        pm.connectAttr("%s.%s" %(ctrl.name(), display_attr), s.visibility)

    pm.delete(text_curve)
    def createManipulatorDynamic(self):

        pm.select(cl=True)

        #createTextCurves
        nurbsText = self.prefix + '_ctrl'
        textCurvesReturnList = pm.textCurves(f='arial', t=nurbsText, ch=True)

        textTopGrp = textCurvesReturnList[0]
        makeTextCurvesNode = textCurvesReturnList[1]

        pm.select(cl=True)

        #get future history of makeTextCurvesNode
        textHistoryList = pm.listHistory(makeTextCurvesNode,
                                         future=True,
                                         af=True)

        #get list of transforms and NurbsCurve nodes connected to makeTextCurvesNode
        textTransformList = []
        textNurbsCurveList = []
        for node in textHistoryList:
            if (pm.nodeType(node) == 'transform'):
                textTransformList.append(node)
            if (pm.nodeType(node) == 'nurbsCurve'):
                textNurbsCurveList.append(node)

        pm.select(cl=True)

        #delete makeTextCurvesNode
        pm.delete(makeTextCurvesNode)
        pm.select(cl=True)

        #iterate through transformList, move pivot to ws (0,0,0) and freeze all
        for transformNode in textTransformList:
            pm.xform(transformNode, ws=True, piv=(0, 0, 0))
            pm.makeIdentity(transformNode, a=True)

        #create manip_dynamicGrp
        self.manip_dynamic = pm.group(n=self.prefix + '_manip_dynamic')
        pm.select(cl=True)

        #iterate through nurbsCurve list and parent shapes under manip ctrlCenter
        for nurbsCurveShape in textNurbsCurveList:
            pm.parent(nurbsCurveShape, self.manip_dynamic, r=True, s=True)

        pm.select(cl=True)

        #create manip_dynamic grp and translate correctly
        self.manip_dynamic_grp = pm.group(n=self.prefix + '_manip_dynamic_grp')
        pm.select(cl=True)
        pm.parent(self.manip_dynamic, self.manip_dynamic_grp)
        pm.select(cl=True)

        self.manip_dynamic_grp.translate.set(self.highResCurveCoordList[0])

        #delete remaining text transform nodes
        pm.delete(textTopGrp)
        pm.select(cl=True)
	def createManipCtrlCenter(self):
		
		pm.select(cl = True)
		
		#createTextCurves
		nurbsText = self.prefix + '_Ctrl'
		textCurvesReturnList = pm.textCurves(f = 'arial' , t = nurbsText, ch = True )
		
		textTopGrp = textCurvesReturnList[0]
		makeTextCurvesNode = textCurvesReturnList[1]
		
		pm.select(cl = True)
		
		#get future history of makeTextCurvesNode
		textHistoryList = pm.listHistory(makeTextCurvesNode, future = True, af = True)
		
		#get list of transforms and NurbsCurve nodes connected to makeTextCurvesNode
		textTransformList = []
		textNurbsCurveList = []
		for node in textHistoryList:
			if(pm.nodeType(node) == 'transform'): textTransformList.append(node)
			if(pm.nodeType(node) == 'nurbsCurve'): textNurbsCurveList.append(node)
			
		pm.select(cl = True)
		
		#delete makeTextCurvesNode
		pm.delete(makeTextCurvesNode)
		pm.select(cl = True)
		
		#iterate through transformList, move pivot to ws (0,0,0) and freeze all
		for transformNode in textTransformList:
			pm.xform(transformNode, ws = True, piv = (0,0,0))
			pm.makeIdentity(transformNode, a = True)
			
			
		#create manipCtrlGrp
		self.manip_CtrlCenter = pm.group(n = self.prefix + '_manip_ctrl_center')
		pm.select(cl = True)
		
		#iterate through nurbsCurve list and parent shapes under manip ctrlCenter
		for nurbsCurveShape in textNurbsCurveList:
			pm.parent(nurbsCurveShape, self.manip_CtrlCenter, r = True, s = True)
			
		pm.select(cl = True)
		
		#create manip_ctrlCenter grp and translate correctly
		self.manip_CtrlCenter_grp = pm.group(n = self.prefix + '_manip_ctrl_center_grp')
		pm.select(cl = True)
		pm.parent(self.manip_CtrlCenter, self.manip_CtrlCenter_grp)
		pm.select(cl = True)
		
		self.manip_CtrlCenter_grp.translate.set(self.jointPositionList[-1][0], self.jointPositionList[-1][1] + 2, self.jointPositionList[-1][2])
		
		
		#delete remaining text transform nodes
		pm.delete(textTopGrp)
		pm.select(cl = True)
def build_text(text):
    # curLabel = pm.PyNode(pm.textCurves(ch=10,f="Times New Roman|h-13|w400|c0", t=text)[0])
    curLabel = pm.PyNode(pm.textCurves(ch=10, f="cafeta|h-13|w400|c0", t=text)[0])
    pm.parent(curLabel.listRelatives(type="nurbsCurve", ad=1), curLabel)
    for transform in curLabel.listRelatives(type="transform", ad=1):
        if not transform.getShape():
            pm.delete(transform)
    curLabel.scale.set(0.2, 0.2, 0.2)
    curLabel.overrideEnabled.set(1)
    curLabel.overrideDisplayType.set(1)
    return curLabel
Beispiel #10
0
def createMeasure():
    sel = pm.selected()
    name = "distanceDimension1_annotation"

    if pm.objExists('measuregroup'):
        print 'exists'
        pm.delete('measuregroup')
    pm.group(n='measuregroup', empty=1)

    pm.setAttr('distanceDimension1.distanceFeet',
               pm.getAttr('distanceDimensionShape1.distance') * 0.0328084)
    t = pm.textCurves(ch=0,
                      f="Utopia-Regular",
                      n=name,
                      t=pm.getAttr('distanceDimension1.distanceFeet'))
    pm.parent(t, 'measuregroup')

    pm.select(sel)
Beispiel #11
0
def create_master_controls(type = "", assetName=""):
    if not type:
        return

    global_round_square_with_arrow = "curve -d 3 -p 0 0 0.75 -p 0.25 0 0.5 -p 0.25 0 0.5 -p 0.25 0 0.5 -p 0.375 0 0.5 -p 0.5 0 0.5 -p 0.5 0 0.375 -p 0.5 0 -0.375 -p 0.5 0 -0.5 -p 0.375 0 -0.5 -p -0.375 0 -0.5 -p -0.5 0 -0.5 -p -0.5 0 -0.375 -p -0.5 0 0.375 -p -0.5 0 0.5 -p -0.375 0 0.5 -p -0.25 0 0.5 -p -0.25 0 0.5 -p -0.25 0 0.5 -p 0 0 0.75 -k 0 -k 0 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -k 16 -k 17 -k 17 -k 17"
    local_round_square_with_arrow = "curve -d 3 -p 0 0 0.5 -p 0.125 0 0.375 -p 0.125 0 0.375 -p 0.125 0 0.375 -p 0.25 0 0.375 -p 0.375 0 0.375 -p 0.375 0 0.25 -p 0.375 0 -0.25 -p 0.375 0 -0.375 -p 0.25 0 -0.375 -p -0.25 0 -0.375 -p -0.375 0 -0.375 -p -0.375 0 -0.25 -p -0.375 0 0.25 -p -0.375 0 0.375 -p -0.25 0 0.375 -p -0.125 0 0.375 -p -0.125 0 0.375 -p -0.125 0 0.375 -p 0 0 0.5 -k 0 -k 0 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -k 16 -k 17 -k 17 -k 17"
    root_crosshair = "curve -d 1 -p 0 0 0.325 -p -0.0634045 0 0.318755 -p -0.124372 0 0.300261 -p -0.180561 0 0.270228 -p -0.22981 0 0.22981 -p -0.270228 0 0.180561 -p -0.300261 0 0.124372 -p -0.318755 0 0.0634045 -p -0.325 0 0 -p -0.318755 0 -0.0634045 -p -0.300261 0 -0.124372 -p -0.270228 0 -0.180561 -p -0.22981 0 -0.22981 -p -0.180561 0 -0.270228 -p -0.124372 0 -0.300261 -p -0.0634045 0 -0.318755 -p 0 0 -0.325 -p 0.0634045 0 -0.318755 -p 0.124372 0 -0.300261 -p 0.180561 0 -0.270228 -p 0.22981 0 -0.22981 -p 0.270228 0 -0.180561 -p 0.300261 0 -0.124372 -p 0.318755 0 -0.0634045 -p 0.325 0 0 -p 0.318755 0 0.0634045 -p 0.300261 0 0.124372 -p 0.270228 0 0.180561 -p 0.22981 0 0.22981 -p 0.180561 0 0.270228 -p 0.124372 0 0.300261 -p 0.0634045 0 0.318755 -p 0 0 0.325 -p 0 0 -0.325 -p 0 0 -0.25 -p -0.0487726 0 -0.245197 -p -0.095671 0 -0.23097 -p -0.138893 0 -0.207868 -p -0.176777 0 -0.176777 -p -0.207868 0 -0.138893 -p -0.23097 0 -0.095671 -p -0.245197 0 -0.0487726 -p -0.25 0 0 -p -0.325 0 0 -p 0.325 0 0 -p -0.25 0 0 -p -0.245197 0 0.0487726 -p -0.23097 0 0.095671 -p -0.207868 0 0.138893 -p -0.176777 0 0.176777 -p -0.138893 0 0.207868 -p -0.095671 0 0.23097 -p -0.0487726 0 0.245197 -p 0 0 0.25 -p 0.0487726 0 0.245197 -p 0.095671 0 0.23097 -p 0.138893 0 0.207868 -p 0.176777 0 0.176777 -p 0.207868 0 0.138893 -p 0.23097 0 0.095671 -p 0.245197 0 0.0487726 -p 0.25 0 0 -p 0.245197 0 -0.0487726 -p 0.23097 0 -0.095671 -p 0.207868 0 -0.138893 -p 0.176777 0 -0.176777 -p 0.138893 0 -0.207868 -p 0.095671 0 -0.23097 -p 0.0487726 0 -0.245197 -p 0 0 -0.25 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -k 16 -k 17 -k 18 -k 19 -k 20 -k 21 -k 22 -k 23 -k 24 -k 25 -k 26 -k 27 -k 28 -k 29 -k 30 -k 31 -k 32 -k 33 -k 34 -k 35 -k 36 -k 37 -k 38 -k 39 -k 40 -k 41 -k 42 -k 43 -k 44 -k 45 -k 46 -k 47 -k 48 -k 49 -k 50 -k 51 -k 52 -k 53 -k 54 -k 55 -k 56 -k 57 -k 58 -k 59 -k 60 -k 61 -k 62 -k 63 -k 64 -k 65 -k 66 -k 67 -k 68 -k 69"
    
    if type == "global": c = pm.mel.eval(global_round_square_with_arrow)
    if type == "local": c = pm.mel.eval(local_round_square_with_arrow)    
    if type == "root": c = pm.mel.eval(root_crosshair)
                        
    if assetName and type == 'global':
        text_curve = pm.PyNode( pm.textCurves(ch=False, font="Arial Black", text=assetName, name='text_curve')[0] )
        text_curve_length = text_curve.boundingBox()[1][0] #max X
        text_curve_height = text_curve.boundingBox()[1][1] #max Y
        
        shapes = pm.listRelatives(text_curve, ad=True, type="shape")
        
        pm.xform(text_curve, piv=[0,text_curve_height,0], ws=True)

        pm.move(text_curve, 0, -text_curve_height ,0.755)
        pm.rotate(text_curve, -90, 45,0)
        
        scales = 0.3535 / text_curve_length
        pm.scale(text_curve, scales, scales, scales)
                
        pm.makeIdentity(text_curve, apply=True, t=True, r=True, s=True)
    
        for s in shapes:
            pm.parent(s, c, s=True, r=True)

        pm.delete(text_curve)
    
    try:
        curve = pm.PyNode(c)
    except:
        pass
    
    return curve
Beispiel #12
0
def add_global_text(global_control, assetName, size):
    if assetName:
        text_curve = pm.PyNode( pm.textCurves(ch=False, font="Arial Black", text=assetName, name='text_curve')[0] )
        text_curve_length = text_curve.boundingBox()[1][0] #max X
        text_curve_height = text_curve.boundingBox()[1][1] #max Y
        
        shapes = pm.listRelatives(text_curve, ad=True, type="shape")
        
        pm.xform(text_curve, piv=[0,text_curve_height,0], ws=True)

        pm.move(text_curve, 0, -text_curve_height ,0.755 * size)
        pm.rotate(text_curve, -90, 45,0)
        
        scales = 0.3535 / text_curve_length * size
        pm.scale(text_curve, scales, scales, scales)
                
        pm.makeIdentity(text_curve, apply=True, t=True, r=True, s=True)
    
        for s in shapes:
            pm.parent(s, global_control, s=True, r=True)
            s.rename('%sText'%global_control.name())                

        pm.delete(text_curve)
Beispiel #13
0
def ikfkCtrlShape(name='ikfk', normalDirection=[0, 1, 0], scale=1):
    ctrl = pm.circle(n=name, s=10, nr=[0, 0, 1])[0]
    pm.delete(ctrl.getShape())

    # create text and snap to displayCtrl group
    textGrp = pm.textCurves(t='IKFK', n=name)[0]
    common.centerPivot(textGrp)
    common.freezeTranform(textGrp)

    # parent al text shape under displayCTrl
    shapeList = pm.ls(textGrp, dag=True, leaf=True, type='nurbsCurve')
    pm.parent(shapeList, ctrl, r=1, s=1)
    pm.delete(textGrp)
    common.centerPivot(ctrl)

    # rotate shape
    for shape in shapeList:
        if normalDirection[0] == 1:
            pm.rotate(shape.cv[:], [90, 0, 0])
        elif normalDirection[0] == -1:
            pm.rotate(shape.cv[:], [-90, 0, 0])

        if normalDirection[1] == 1:
            pm.rotate(shape.cv[:], [0, 90, 0])
        elif normalDirection[1] == -1:
            pm.rotate(shape.cv[:], [0, -90, 0])

        if normalDirection[2] == 1:
            pm.rotate(shape.cv[:], [0, 0, 90])
        elif normalDirection[2] == -1:
            pm.rotate(shape.cv[:], [0, 0, -90])

    pm.scale(ctrl, [scale, scale, scale], r=True)
    common.centerPivot(ctrl)
    common.freezeTranform(ctrl)

    return ctrl
Beispiel #14
0
    def __init__(self, **kwds):

        self.character = defaultReturn('jerry', 'character', param=kwds)
        self.rigBound = defaultReturn(None, 'rigBound', param=kwds)
        self.rigVersion = defaultReturn(0, 'version', param=kwds)
        self.buildInScene = defaultReturn(0, 'buildInScene', param=kwds)

        if self.buildInScene == 0:
            pm.newFile(f=True)

        print "START: rigPuppet build " + self.character
        pm.timer(s=True)
        pm.undoInfo(state=False)
        pm.evaluationManager(mode='serial')

        try:
            self.charModule = importlib.import_module('char.' +
                                                      self.character +
                                                      'Puppet')
            print self.charModule

            pm.workspace(update=True)
            projectRoot = pm.workspace(
                q=True,
                rd=True) + 'scenes/release/rigBound/' + self.character + '/'
            print ' project root ' + projectRoot + ' found'

            if self.rigVersion == 0:
                puppetPath = pm.workspace(
                    q=True, rd=True
                ) + 'scenes/release/rigPuppet/' + self.character + '/'
                # find what is next puppet version
                puppetList = []
                os.chdir(puppetPath)
                for f in glob.glob("*.ma"):
                    puppetList.append(f)
                self.rigVersion = len(puppetList) + 1
                print 'rigVersion = ' + str(self.rigVersion)

            if self.rigBound is None:
                #projectRoot = pm.workspace(q=True, rd=True) + 'scenes/release/rigBound/'
                fileList = []
                os.chdir(projectRoot)
                for f in glob.glob("*.ma"):
                    fileList.append(f)

                fileList.sort()
                latestFile = fileList[-1:][0]
                self.rigBound = projectRoot + latestFile
                print 'latestFile = ' + latestFile
            #else:
            #   self.rigBound = projectRoot + self.rigBound + '.ma'

            if self.buildInScene == 0:
                print 'rigBound file path = ' + self.rigBound
                # import rigBound file
                try:
                    #filePath = cmds.file(self.rigBound, f=True, ignoreVersion=True,
                    # typ="mayaAscii", o=True)
                    filePath = cmds.file(self.rigBound,
                                         i=True,
                                         ignoreVersion=True,
                                         ra=False,
                                         mergeNamespacesOnClash=False,
                                         typ="mayaAscii",
                                         loadReferenceDepth='none')

                except RuntimeError:
                    print self.rigBound + ' file not found'

            cmds.dgdirty(allPlugs=True)
            cmds.refresh()

            # unparent skeleton
            rootJoint = cmds.parent(cmds.listRelatives('skeleton_GRP',
                                                       typ='joint'),
                                    w=True)[0]

            loadPose(rootJoint, 'tPose')

            pm.rename('globalOffset_GRP', 'globalOffset_GRPx')
            pm.rename('global_CTRL', 'global_CTRLx')

            self.globalCtrl = rig_control(name='global',
                                          colour='white',
                                          shape='arrows',
                                          con=0,
                                          showAttrs=['sx', 'sy', 'sz'])

            self.globalCtrl.gimbal = createCtrlGimbal(self.globalCtrl).ctrl

            self.topNode = rig_transform(0,
                                         name=self.character + 'RigPuppetTop',
                                         child=self.globalCtrl.offset).object

            topNode = pm.PyNode(self.topNode)

            pm.addAttr(topNode,
                       ln='rpAuthor',
                       at='enum',
                       enumName='JerryLee',
                       k=True)
            topNode.rpAuthor.setLocked(True)
            pm.addAttr(topNode,
                       ln='rpVersion',
                       at='enum',
                       enumName=str(self.rigVersion),
                       k=True)
            topNode.rpVersion.setLocked(True)

            topNode.translate.setLocked(True)
            topNode.rotate.setLocked(True)
            topNode.scale.setLocked(True)
            for cb in ('t', 'r', 's'):
                for at in ('x', 'y', 'z'):
                    cbAttr = getattr(topNode, cb + at)
                    cbAttr.setKeyable(False)

            try:
                self.rigGrp = pm.parent('rig_GRP', self.globalCtrl.gimbal)[0]
            except Exception as e:
                self.rigGrp = rig_transform(
                    0, name='rig', parent=self.globalCtrl.gimbal).object
                pm.addAttr(self.rigGrp,
                           longName='worldScale',
                           at='float',
                           k=True,
                           min=0,
                           defaultValue=1)
                self.rigGrp.worldScale.set(cb=True)

            try:
                self.rigModule = pm.parent('rigModules_GRP',
                                           self.globalCtrl.gimbal)[0]
            except Exception as e:
                self.rigModule = rig_transform(
                    0, name='rigModules', parent=self.globalCtrl.gimbal).object

            try:
                self.model = pm.parent('model_GRP', self.topNode)[0]
            except Exception as e:
                self.model = rig_transform(0,
                                           name='model',
                                           parent=self.topNode).object

            try:
                self.rigModel = pm.parent('rigModel_GRP', self.model)[0]
            except Exception as e:
                self.rigModel = rig_transform(0,
                                              name='rigModel',
                                              parent=self.model).object

            self.worldSpace = rig_transform(
                0, name='worldSpace', parent=self.globalCtrl.gimbal).object

            try:
                pm.delete("|*RigBoundTop_GRP")
            except pm.MayaNodeError:
                print 'RigBound top node does not exist'

            # create attributes on global ctrl
            pm.addAttr(self.globalCtrl.ctrl,
                       ln='puppetSettings',
                       at='enum',
                       enumName='___________',
                       k=True)
            self.globalCtrl.ctrl.puppetSettings.setLocked(True)

            # model and skeleton vis
            # model
            connectAttrToVisObj(self.globalCtrl.ctrl,
                                'modelVis',
                                self.model,
                                defaultValue=1)
            # skeleton
            pm.addAttr(self.globalCtrl.ctrl,
                       longName='skeletonVis',
                       at='long',
                       k=True,
                       min=0,
                       max=1,
                       defaultValue=0)
            self.globalCtrl.ctrl.skeletonVis.set(cb=True)
            # controls
            pm.addAttr(self.globalCtrl.ctrl,
                       longName='controlsVis',
                       at='long',
                       k=True,
                       min=0,
                       max=1,
                       defaultValue=1)
            self.globalCtrl.ctrl.controlsVis.set(cb=True)

            # referencing and selecting
            pm.addAttr(self.globalCtrl.ctrl,
                       ln='model',
                       at='enum',
                       enumName='Selectable:Reference',
                       k=True,
                       defaultValue=1)
            pm.addAttr(self.globalCtrl.ctrl,
                       ln='skeleton',
                       at='enum',
                       enumName='Selectable:Reference',
                       k=True,
                       defaultValue=1)

            # LOD vis
            pm.addAttr(self.globalCtrl.ctrl,
                       ln='lodSetting',
                       at='enum',
                       enumName='___________',
                       k=True)
            self.globalCtrl.ctrl.lodSetting.setLocked(True)
            pm.addAttr(self.globalCtrl.ctrl,
                       ln='lodDisplay',
                       at='enum',
                       enumName='Low:Mid:High',
                       k=True,
                       defaultValue=0)

            lodModel = [
                'lowLOD_GRP', 'lowMidLOD_GRP', 'midLOD_GRP', 'midHighLOD_GRP',
                'highLOD_GRP'
            ]

            for lod in lodModel:
                if pm.objExists(lod):
                    lodGRP = pm.PyNode(lod)
                    if 'low' in lod:
                        pm.setDrivenKeyframe(
                            lodGRP.visibility,
                            cd=self.globalCtrl.ctrl.lodDisplay,
                            dv=0,
                            v=1)
                        pm.setDrivenKeyframe(
                            lodGRP.visibility,
                            cd=self.globalCtrl.ctrl.lodDisplay,
                            dv=1,
                            v=0)
                    if 'mid' in lod:
                        pm.setDrivenKeyframe(
                            lodGRP.visibility,
                            cd=self.globalCtrl.ctrl.lodDisplay,
                            dv=0,
                            v=0)
                        pm.setDrivenKeyframe(
                            lodGRP.visibility,
                            cd=self.globalCtrl.ctrl.lodDisplay,
                            dv=1,
                            v=1)
                        pm.setDrivenKeyframe(
                            lodGRP.visibility,
                            cd=self.globalCtrl.ctrl.lodDisplay,
                            dv=2,
                            v=0)
                    if 'high' in lod:
                        pm.setDrivenKeyframe(
                            lodGRP.visibility,
                            cd=self.globalCtrl.ctrl.lodDisplay,
                            dv=0,
                            v=0)
                        pm.setDrivenKeyframe(
                            lodGRP.visibility,
                            cd=self.globalCtrl.ctrl.lodDisplay,
                            dv=1,
                            v=0)
                        pm.setDrivenKeyframe(
                            lodGRP.visibility,
                            cd=self.globalCtrl.ctrl.lodDisplay,
                            dv=2,
                            v=1)
                    if 'lowMid' in lod:
                        pm.setDrivenKeyframe(
                            lodGRP.visibility,
                            cd=self.globalCtrl.ctrl.lodDisplay,
                            dv=0,
                            v=1)
                        pm.setDrivenKeyframe(
                            lodGRP.visibility,
                            cd=self.globalCtrl.ctrl.lodDisplay,
                            dv=1,
                            v=1)
                        pm.setDrivenKeyframe(
                            lodGRP.visibility,
                            cd=self.globalCtrl.ctrl.lodDisplay,
                            dv=2,
                            v=0)
                    if 'midHigh' in lod:
                        pm.setDrivenKeyframe(
                            lodGRP.visibility,
                            cd=self.globalCtrl.ctrl.lodDisplay,
                            dv=0,
                            v=0)
                        pm.setDrivenKeyframe(
                            lodGRP.visibility,
                            cd=self.globalCtrl.ctrl.lodDisplay,
                            dv=1,
                            v=1)
                        pm.setDrivenKeyframe(
                            lodGRP.visibility,
                            cd=self.globalCtrl.ctrl.lodDisplay,
                            dv=2,
                            v=1)

            if cmds.objExists('allModel_GRP'):
                cmds.setAttr("allModel_GRP.visibility", 1)

            # scale global control
            self.bbox = self.model.boundingBox()
            width = self.bbox.width() * 0.3
            cvsGlobal = pm.PyNode(self.globalCtrl.ctrl + '.cv[:]')
            cvsGimbal = pm.PyNode(self.globalCtrl.gimbal + '.cv[:]')
            pm.scale(cvsGlobal, width, width, width)
            pm.scale(cvsGimbal, width / 1.5, width / 1.5, width / 1.5)

            # make display toggle
            self.displayTransform = pm.circle(
                name='displayModulesToggleControl', sw=360, nr=(0, 1, 0),
                ch=0)[0]
            pm.delete(self.displayTransform.getShape())

            displayCurves = pm.PyNode(
                pm.textCurves(f="Quartz|wt:50|sz:28|sl:n|st:100",
                              t="Display",
                              ch=0,
                              fzn=True)[0])
            pm.setAttr(displayCurves.translateX, -1.7)
            pm.move(0, 0, 0, displayCurves.rotatePivot, p=True, ws=True)
            pm.move(0, 0, 0, displayCurves.scalePivot, p=True, ws=True)

            pm.move(0, (self.bbox.height() + (self.bbox.height() * 0.1)),
                    0,
                    displayCurves,
                    r=True)
            displayScale = self.bbox[1][0] / 4
            pm.scale(displayCurves, displayScale, displayScale, displayScale)

            allCurves = pm.listRelatives(displayCurves,
                                         ad=True,
                                         c=True,
                                         type="nurbsCurve")
            parentCurves = []
            for crv in allCurves:
                parentTransform = pm.listRelatives(crv, p=True)[0]
                pm.parent(parentTransform, w=True)
                pm.makeIdentity(parentTransform, apply=True, t=1, r=1, s=1)
                pm.parent(crv, self.displayTransform, shape=True, add=True)
                parentCurves.append(parentTransform)

            pm.dgdirty(allPlugs=True)
            pm.refresh()
            pm.delete(parentCurves, s=False)
            pm.delete(displayCurves)
            pm.parent(self.displayTransform, self.globalCtrl.ctrl)
            for at in [
                    'translateX', 'translateY', 'translateZ', 'rotateX',
                    'rotateY', 'rotateZ', 'scaleX', 'scaleY', 'scaleZ',
                    'visibility'
            ]:
                #getattr(self.displayTransform, at).set(k=False)
                self.displayTransform.attr(at).set(k=False)
                self.displayTransform.attr(at).setLocked(True)

            pm.connectAttr(self.globalCtrl.ctrl + '.scaleX',
                           self.rigGrp.worldScale)
            pm.hide(self.rigGrp, self.rigModel)

            pm.addAttr(self.globalCtrl.ctrl,
                       ln='rigAuthor',
                       at='enum',
                       enumName='Jerry:Lee',
                       k=False,
                       dv=0)

            self.prepareRig()

            self.createRigModules()

            self.finishRig()

            pm.select(cl=True)

            #self.sup = super(puppet, self)
            #self.sup.__init__(self.topNode, **kwds)

        except Exception as e:
            print "*************************************"
            print "=========== Error happened ========="
            raise
        finally:
            pm.evaluationManager(mode='parallel')

            mayaTimer = pm.timer(e=True)

            pm.undoInfo(state=True)
            print ''
            print ''
            print "END: rigPuppet built in %g seconds" % mayaTimer
            print ''
    def makeWord(self, in_word):
        """ create particle word"""

        #    in_word='maya'
        #    font = 'Arial'
        #    font = self.fontChoose.currentFont()
        #    print self.font[-1]
        tCrvs = pm.textCurves(t=in_word, f=self.font, ch=0)
        tCrvs = pm.PyNode(tCrvs[0])

        letterNum = tCrvs.numChildren()
        letter = []
        grpWord = pm.group(em=True)
        for n in range(0, letterNum):
            letterShape = pm.listRelatives(tCrvs.getChildren()[n],
                                           type='nurbsCurve',
                                           ad=True,
                                           path=True)
            letter.append(
                pm.planarSrf(letterShape, ch=1, tol=0.01, o=1, po=1)[0])
        pm.parent(letter, grpWord)

        # pm.select(grpWord)
        wordshape = pm.polyUnite(ch=1, muv=1)[0]
        mc.DeleteHistory()
        wordshape = pm.PyNode(wordshape)
        self.word.append(wordshape)
        # see(wordshape)

        pm.setAttr(tCrvs + ".visibility", 0)
        wordshape.centerPivots()
        # pm.move(-8,0,0)
        pm.makeIdentity(apply=True, t=1, r=1, s=1, n=0, pn=1)
        wordshape.makeLive()

        wordshape.select()
        pm.emitter(type='surface', r=1000, spd=0)
        wordEmitter = wordshape.getChildren()[1]
        wordEmitter = pm.PyNode(wordEmitter)
        wordEmitter.cycleEmission.set(1)
        wordEmitter.maxDistance.set(5)
        # see(wordEmitter)
        # wordEmitter.select()
        wordParticle = pm.particle()[0]
        wordParticle = pm.PyNode(wordParticle)
        wordPaShape = wordParticle.getShape()
        self.wordPar.append(wordPaShape)
        pm.connectDynamic(wordParticle, em=wordEmitter)
        mc.setKeyframe([wordEmitter + ".rate"], v=200, t=100)
        mc.setKeyframe([wordEmitter + ".rate"], v=0, t=101)

        wordPaShape.lifespanMode.set(2)
        wordPaShape.attr("lifespan").set(5)
        wordPaShape.lifespanRandom.set(3)

        wordPaShape.particleRenderType.set(0)
        wordPaShape.addAttr('colorAccum',
                            dv=True,
                            at='bool',
                            internalSet=True,
                            keyable=True)
        wordPaShape.addAttr('useLighting',
                            dv=False,
                            at='bool',
                            internalSet=True)
        wordPaShape.addAttr('multiCount',
                            at='long',
                            min=1,
                            max=60,
                            dv=2,
                            internalSet=True)
        wordPaShape.addAttr('multiRadius',
                            at='float',
                            min=1,
                            max=60,
                            dv=0.3,
                            internalSet=True)
        wordPaShape.addAttr('normalDir',
                            min=1,
                            max=3,
                            at='long',
                            internalSet=True,
                            dv=2)
        wordPaShape.addAttr('pointSize',
                            min=1,
                            max=60,
                            at='long',
                            internalSet=True,
                            dv=2)
        wordPaShape.colorAccum.set(1)
        wordPaShape.multiCount.set(7)
        wordPaShape.pointSize.set(1)

        wordPaShape.addAttr('goalU', dt='doubleArray', keyable=True)
        wordPaShape.addAttr('goalV', dt='doubleArray', keyable=True)
        pm.dynExpression(wordPaShape,
                         s='goalU=rand(0,1);\ngoalV=rand(0,1);',
                         c=1)
        wordPaShape.addAttr('rgbPP', dt='vectorArray', keyable=True)
        pm.dynExpression(wordPaShape, s='rgbPP=position;', rbd=1)

        pm.goal(wordParticle, g=wordshape, w=1, utr=0)
        pm.setKeyframe(wordParticle, attribute='goalWeight[0]', v=1, t=90)
        pm.setKeyframe(wordParticle, attribute='goalWeight[0]', v=0, t=100)
        pm.setAttr(wordshape + ".visibility", 0)

        field = pm.turbulence(pos=(0, 0, 2), m=10)
        pm.connectDynamic(wordParticle, f=field)
        pm.setKeyframe(field, attribute='tx', v=12, t=100)
        pm.setKeyframe(field, attribute='tx', v=0, t=110)
        pm.parent(field, wordshape)

        lambert = pm.shadingNode('lambert', asShader=1)
        lambertSG = pm.sets(renderable=True,
                            empty=1,
                            noSurfaceShader=True,
                            name=lambert + "SG")
        pm.connectAttr(lambert + ".outColor",
                       lambert + "SG.surfaceShader",
                       f=1)
        # pm.sets(wordParticle,forceElement='lambert6SG',e=True)
        wordParticle.select()
        pm.hyperShade(a=lambertSG)
        self.wordTexture.append(lambert)
        pm.setAttr(lambert + ".transparency", 0.7, 0.7, 0.7, type='double3')
        pm.setAttr(lambert + ".incandescence", 0.6, 0.6, 0.6, type='double3')
        pm.setAttr(lambert + ".incandescence", 0.5, 0.5, 0.5, type='double3')
        pm.setAttr(lambert + ".glowIntensity", 0.6)

        wordshape.select()