def ctrl_text(var): """ Creates letters and text made from multipe curves. """ cmds.textCurves(ch=0, f='Times New Roman', t=var) cmds.ungroup() cmds.ungroup() print 'Curves have been ungrouped.' curves = cmds.ls(sl=True) cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=0) print 'Freezing transforms on curves.' cmds.pickWalk(d='Down') shapes = cmds.ls(sl=True) print 'Creating a list of curve shape nodes.' parent_shapes = shapes[1:] delete_curves = curves[1:] print 'Slicing lists for parenting and deleting purposes.' cmds.select(parent_shapes, r=True) cmds.select(curves[0], add=True) cmds.parent(r=True, s=True) print 'Curve list has been parented into single curve.' cmds.select(delete_curves, r=True) mel.eval('doDelete') print 'Unused groups have been deleted.' cmds.select(curves[0]) mel.eval('CenterPivot') print ('End result curve have been selected and its pivot has been centered.')
def createBoxControl(ctrlName): mc.curve(d=1,p=[[-1,1,0],[1,1,0],[1,-1,0],[-1,-1,0],[-1,1,0]],n=ctrlName+'_limitBox') mc.circle(n=ctrlName, nr=[0,0,1],r=.1) mc.transformLimits(ctrlName,etx=[True,True],ety=[True,True]) mc.textCurves(t=ctrlName,n=ctrlName+'_text') mc.setAttr(ctrlName+'_textShape.ty',1.1) mc.setAttr(ctrlName+'_textShape.tx',-1) mc.setAttr(ctrlName+'_textShape.sy',.3) mc.setAttr(ctrlName+'_textShape.sx',.3) mc.select(ctrlName+'_textShape',hi=True) textSel=mc.ls(sl=True) for obj in textSel: mc.setAttr(obj+'.template',1) mc.parent(ctrlName,ctrlName+'_textShape',ctrlName+'_limitBox') mc.setAttr(ctrlName+'.tz',lock=True,k=False,channelBox=False) mc.setAttr(ctrlName+'.rx',lock=True,k=False,channelBox=False) mc.setAttr(ctrlName+'.ry',lock=True,k=False,channelBox=False) mc.setAttr(ctrlName+'.rz',lock=True,k=False,channelBox=False) mc.setAttr(ctrlName+'.sz',lock=True,k=False,channelBox=False) mc.setAttr(ctrlName+'.sx',lock=True,k=False,channelBox=False) mc.setAttr(ctrlName+'.sy',lock=True,k=False,channelBox=False) mc.setAttr(ctrlName+'.v',lock=True,k=False,channelBox=False)
def ctrl_text(var): """ Creates letters and text made from multipe curves. """ cmds.textCurves(ch=0, f='Times New Roman', t=var) cmds.ungroup() cmds.ungroup() print 'Curves have been ungrouped.' curves = cmds.ls(sl=True) cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=0) print 'Freezing transforms on curves.' cmds.pickWalk(d='Down') shapes = cmds.ls(sl=True) print 'Creating a list of curve shape nodes.' parent_shapes = shapes[1:] delete_curves = curves[1:] print 'Slicing lists for parenting and deleting purposes.' cmds.select(parent_shapes, r=True) cmds.select(curves[0], add=True) cmds.parent(r=True, s=True) print 'Curve list has been parented into single curve.' cmds.select(delete_curves, r=True) mel.eval('doDelete') print 'Unused groups have been deleted.' cmds.select(curves[0]) mel.eval('CenterPivot') print( 'End result curve have been selected and its pivot has been centered.')
def create(self): """create pivot object""" front = mc.textCurves( n= self.assetName + 'front_grp', f='Courier|w400|h-11', t='Front' ) mc.delete( front[1] ) front = mn.Node( front[0] ) left = mc.textCurves( n= self.assetName + 'left_grp', f='Courier|w400|h-11', t='Left' ) mc.delete( left[1] ) left = mn.Node( left[0] ) left.a.ry.v = 90 left.a.tx.v = 10 top = mc.textCurves( n= self.assetName + 'top_grp', f='Courier|w400|h-11', t='Top' ) mc.delete( top[1] ) top = mn.Node( top[0] ) top.a.rx.v = -90 top.a.ty.v = 10 box = mc.curve( d = 1, p = [(0,0,0), (10,0,0), (10,10,0), (0,10,0), (0,0,0), (0,0,-10), (10,0,-10), (10,0,0), (10,10,0), (10,10,-10), (10,0,-10), (10,10,-10), (10, 10, 0), (0,10,0), (0,10,-10), (10,10,-10), (10,0,-10), (0,0,-10), (0,10,-10)], k = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18], n = self.assetName + 'box' ) grp = mn.Node( mc.group( front.name, left.name, top.name, box, n = self.name ) ) self.setPivot( [5,5,-5] ) grp.a.t.v = [-5,-5,5] mc.makeIdentity( grp.name, apply = True, t = True, r = True, s = True, n = 1 ) curves = mc.ls( grp.name, dag = True, typ = 'nurbsCurve' ) mc.parent( curves, grp.name, add=True, shape = True ) mc.delete( front.name, left.name, top.name, box )
def ctrl_letter(var): """ Creates letters made from single curves. """ cmds.textCurves(ch=0, f='Times New Roman', t=var) cmds.ungroup() cmds.ungroup() mel.eval('CenterPivot') print 'Curve has been selected and its pivot as been centered.'
def missing_rigs(): project_path = project_path_base + '/' + project_name assets_path = project_path + '/prod/assets/' asset_type = os.listdir(assets_path) asset_name = [] asset_list = [] for each in asset_type: asset_path = assets_path + each + '/' print(asset_path) asset_name.append(asset_path) print(asset_name) for each in asset_name: assets = os.listdir(each) for each in assets: asset_list.append(each) print(asset_list) for typ in asset_type: print(typ) path = assets_path + typ for each in os.listdir(path): state_path = path + '/' + each states = os.listdir(state_path) print('states == > ' + str(state_path)) if not 'rig' in states: print(each + ' has no rig folder') go_on = mc.confirmDialog(title='Missing Rig !', message='The asset ' + each + ' has no rig folder, create it ?', button=['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No') if go_on == 'Yes': mkfolder.cr_folder(state_path + '\\rig', 777) mkfolder.cr_folder(state_path + '\\rig\\V000', 777) mc.file(new=True, f=True) mc.textCurves(f='Arial|wt:75|sz:100|sl:n|st:100', t=each) mc.file(rename=state_path + '\\rig\\V000\\' + 'rig') mc.file(save=True, type='mayaAscii')
def jointCreator(name, pos, type, side): mc.select(cl=True) jointName = side + '_' + name + '_' + type mc.joint(n=jointName, p=pos) mc.textCurves(n=name, t=name) mc.parent(name + 'Shape', jointName) mc.setAttr(name + 'Shape.tx', 0) mc.setAttr(name + 'Shape.ty', 0) mc.setAttr(name + 'Shape.tz', 0) #add to list of joints jointsList.append(jointName) #add text textList.append(name + 'Shape')
def create_text(text): cmds.textCurves(ch=0, t=text) print(text) cmds.ungroup() cmds.ungroup() curves = cmds.ls(sl=True) cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=0) shapes = curves[1:] cmds.select(shapes, r=True) cmds.pickWalk(d='Down') cmds.select(curves[0], tgl=True) cmds.parent(r=True, s=True) cmds.pickWalk(d='up') cmds.delete(shapes) cmds.xform(cp=True) return cmds.ls(sl=True)[0]
def addText(obj, t='A', f='Arial-Bold', c=12, rotOffset=[0, 0, 0], posOffset=[-1, 10, 0]): '''\n obj = transform to recieve text t = text f = font c = color ''' shapes = [] text = cmds.textCurves(ch=0, f=f, t=t) # xform text pos = cmds.xform(obj, q=True, rp=True, ws=True) rot = cmds.xform(obj, q=True, ro=True, ws=True) cmds.xform(text, t=pos, ro=rot) # get selection cmds.select(text, hi=True) sel = cmds.ls(sl=True) # find shapes for item in sel: if cmds.objectType(item) != 'transform': # offset cmds.rotate(rotOffset[0], rotOffset[1], rotOffset[2], item + '.cv[*]', r=True, eu=True, p=pos) cmds.move(posOffset[0], posOffset[1], posOffset[2], item + '.cv[*]', r=True, ls=True, wd=True) # assemble cmds.setAttr(item + '.overrideEnabled', 1) cmds.setAttr(item + '.overrideColor', c) cmds.parent(item, obj, r=True, s=True) cmds.rename(item, obj + 'Shape') # delete left overs cmds.delete(text)
def showAllNumbers(self): "Method to apply number on each vertex (for debugging only...)" for i in range(self.numPoints): txt = cmds.textCurves(text=str(i)) cmds.scale(.5, .5, .5) cmds.move(self.vertices[i][0], self.vertices[i][1], self.vertices[i][2], txt)
def createCtrl(): animFixCtrl=mc.textCurves(ch=0,o=1,f='Times New Roman|w400|h-1',t='AnimFixCtrl',n='Ctrl_AnimFix') curveShapes=mc.listRelatives(animFixCtrl,allDescendents=1,type='nurbsCurve') children=mc.listRelatives(animFixCtrl,children=1) makeCurve=mc.listConnections(children[0],s=1) mc.delete(makeCurve) mc.makeIdentity(animFixCtrl,apply=1) for i in curveShapes: mc.parent(i,animFixCtrl,s=1,add=1) mc.delete(children) animFixCtrl=mc.rename(animFixCtrl,'animFixCtrl') mc.setAttr(animFixCtrl+".overrideEnabled",1) mc.setAttr(animFixCtrl+".overrideColor",17) mc.setAttr("animFixCtrl.tx",keyable=0,channelBox=1) mc.setAttr("animFixCtrl.ty",keyable=0,channelBox=1) mc.setAttr("animFixCtrl.tz",keyable=0,channelBox=1) mc.setAttr("animFixCtrl.rx",keyable=0,channelBox=1) mc.setAttr("animFixCtrl.ry",keyable=0,channelBox=1) mc.setAttr("animFixCtrl.rz",keyable=0,channelBox=1) mc.setAttr("animFixCtrl.sx",keyable=0,channelBox=1) mc.setAttr("animFixCtrl.sy",keyable=0,channelBox=1) mc.setAttr("animFixCtrl.sz",keyable=0,channelBox=1) mc.setAttr("animFixCtrl.v",keyable=0,channelBox=1) activeCam=mc.lookThru(q=1) ctrlGrp=mc.group(animFixCtrl,n='animFixCtrlGRP') mainGrp=mc.group(em=1,n='animFixGrp') mc.parent(ctrlGrp,activeCam) mc.xform(ctrlGrp,a=1,os=1,t=[0.3,0.7,-5],ro=[0,0,0]) mc.parent(ctrlGrp,mainGrp) mc.parentConstraint(activeCam,ctrlGrp,mo=1) mc.select(animFixCtrl,r=1)
def shot_camera(shot_num): cam_path = project_dir + '/utils/camera/camera.mb' shot_num = padding_numbers.padder(int(shot_num), 3) new_cam = mc.file(cam_path, i=True) new_cam = mc.rename('shot_num', 'shot_' + shot_num) def lockHideAttr(obj, attrArray, lock, hide): for a in attrArray: mc.setAttr(obj + '.' + a, k=hide, l=lock) text_curves = mc.textCurves(n='sh_' + shot_num, ch=0, f='Arial|wt:75|sz:8|sl:n|st:100', t='SH_' + shot_num) text_curves = mc.rename(text_curves, 'sh_' + shot_num + '__txt') mc.xform(text_curves, ws=True, ro=[0, 180, 0], t=[-0.2, 1, 0]) mc.parent(text_curves, new_cam) lockHideAttr(text_curves, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz'], True, False) try: mc.parent(new_cam, 'cams') except: sys.exit('No folder <cams> in the scene !!')
def createController(ctrlName, charName, alignment): #Create the limit box mc.nurbsSquare(name=charName + '_' + ctrlName + '_limitBox') mc.setAttr(charName + '_' + ctrlName + '_limitBox.scaleX', 2.5) mc.setAttr(charName + '_' + ctrlName + '_limitBox.scaleY', 2.5) mc.makeIdentity(apply=True, scale=True) mc.setAttr('top' + charName + '_' + ctrlName + '_limitBox.template', True) mc.setAttr('left' + charName + '_' + ctrlName + '_limitBox.template', True) mc.setAttr('bottom' + charName + '_' + ctrlName+ '_limitBox.template', True) mc.setAttr('right' + charName + '_' + ctrlName+ '_limitBox.template', True) #Create handle ctrlHandleName = charName + '_' + ctrlName + '_ctrl' mc.circle(name=ctrlHandleName) mc.setAttr(charName + '_' + ctrlName + '_ctrl.scaleX', .2) mc.setAttr(charName + '_' + ctrlName + '_ctrl.scaleY', .2) mc.makeIdentity(apply=True, scale=True) #Limit the handle transform so that it will be only moving within the box mc.transformLimits(tx=(-1, 1), etx=(True, True)) mc.transformLimits(tx=(-1, 1), ety=(True, True)) #Lock rotation, scale and translate on Z-axis mc.setAttr(charName + '_' + ctrlName + '_ctrl.translateZ', lock=True, keyable=False, channelBox=False) mc.setAttr(charName + '_' + ctrlName + '_ctrl.rotateX', lock=True, keyable=False, channelBox=False) mc.setAttr(charName + '_' + ctrlName + '_ctrl.rotateY', lock=True, keyable=False, channelBox=False) mc.setAttr(charName + '_' + ctrlName + '_ctrl.rotateZ', lock=True, keyable=False, channelBox=False) mc.setAttr(charName + '_' + ctrlName + '_ctrl.scaleX', lock=True, keyable=False, channelBox=False) mc.setAttr(charName + '_' + ctrlName + '_ctrl.scaleY', lock=True, keyable=False, channelBox=False) mc.setAttr(charName + '_' + ctrlName + '_ctrl.scaleZ', lock=True, keyable=False, channelBox=False) mc.setAttr(charName + '_' + ctrlName + '_ctrl.visibility', lock=True, keyable=False, channelBox=False) #alignment if alignment == 'center': colorYellow(ctrlHandleName) elif alignment == 'right': colorRed(ctrlHandleName) else: colorBlue(ctrlHandleName) mc.textCurves(text=ctrlName, name=charName + '_' + ctrlName + '_label_') mc.setAttr(charName + '_' + ctrlName + '_label_Shape.translateX', -1.2) mc.setAttr(charName + '_' + ctrlName + '_label_Shape.translateY', 1.3) mc.setAttr(charName + '_' + ctrlName + '_label_Shape.scaleX', .5) mc.setAttr(charName + '_' + ctrlName + '_label_Shape.scaleY', .5) mc.setAttr(charName + '_' + ctrlName + '_label_Shape.scaleZ', .5) mc.setAttr(charName + '_' + ctrlName + '_label_Shape.template', True) mc.parent(charName + '_' + ctrlName + '_ctrl', charName + '_' + ctrlName + '_label_Shape', charName + '_' + ctrlName + '_limitBox')
def createShape(prefix=''): """ Create a vertical slider control with proper name :param prefix: str, prefixName of the control :return: list(str), [sliderPath, mainCtrlBox] """ # create slider ctrl = cmds.circle(radius=0.15, nr=(0, 1, 0), n=prefix + '_Ctrl')[0] cmds.transformLimits(ctrl, tx=(-1, 1), ty=(0, 0), tz=(0, 0), etx=(1, 1), ety=(1, 1), etz=(1, 1)) ctrlBox = cmds.curve(d=1, p=[(-1, 0, 0), (1, 0, 0)], k=[0, 1], n=prefix + '_Path') parentCrvShape = cmds.listRelatives(ctrlBox, s=1) cmds.setAttr(parentCrvShape[0] + '.template', 1) cmds.parent(ctrl, ctrlBox) cmds.select(cl=1) # create text textCrv = cmds.textCurves(n=prefix + '_text', font='Times-Roman', t=name.removeSuffix(prefix))[0] cmds.setAttr(textCrv + '.overrideEnabled', 1) cmds.setAttr(textCrv + '.overrideDisplayType', 2) cmds.setAttr(textCrv + '.s', 0.5, 0.5, 0.5) cmds.setAttr(textCrv + '.rx', 90) cmds.makeIdentity(textCrv, apply=1, t=0, r=1, s=1) textHeight = cmds.getAttr(textCrv + '.boundingBoxMaxZ') textWidth = cmds.getAttr(textCrv + '.boundingBoxMaxX') cmds.setAttr(textCrv + '.tx', (0 - (textWidth/2))) cmds.setAttr(textCrv + '.tz', 0.65) betterWidth = 1.15 if textWidth/2 >= 1.15: betterWidth = textWidth/2 # create Main CtrlBox mainCtrlBox = cmds.curve(d=1, p=[((0 - (betterWidth + 0.2)), 0, (0.85 + textHeight)), ((betterWidth + 0.2), 0, (0.85 + textHeight)), ((betterWidth + 0.2), 0, -0.35), ((0 - (betterWidth + 0.2)), 0, -0.35), ((0 - (betterWidth + 0.2)), 0, (0.85 + textHeight))], k=[0, 1, 2, 3, 4], n=prefix + '_ctrlBox') parentCrvShape1 = cmds.listRelatives(mainCtrlBox, s=1) cmds.setAttr(parentCrvShape1[0] + '.template', 1) # clean hierarchy cmds.parent(ctrlBox, mainCtrlBox) cmds.parent(textCrv, mainCtrlBox) cmds.makeIdentity(mainCtrlBox, apply=1, t=0, r=1, s=1) cmds.select(cl=1) return [ctrlBox, mainCtrlBox]
def Lab_coordinates_system_representation(): """ Creates a *CIE L\\*a\\*b\\** coordinates system representation. Returns ------- bool Definition success. """ group = cmds.createNode('transform') cube = cmds.polyCube(w=600, h=100, d=600, sx=12, sy=2, sz=12, ch=False)[0] set_attributes({ '{0}.translateY'.format(cube): 50, '{0}.overrideEnabled'.format(cube): True, '{0}.overrideDisplayType'.format(cube): 2, '{0}.overrideShading'.format(cube): False }) cmds.makeIdentity(cube, apply=True, t=True, r=True, s=True) cmds.select(['{0}.f[0:167]'.format(cube), '{0}.f[336:359]'.format(cube)]) cmds.delete() cmds.nurbsToPolygonsPref(polyType=1, chordHeightRatio=0.975) for label, position, name in (('-a*', (-350, 0), 'minus_a'), ('+a*', (350, 0), 'plus_a'), ('-b*', (0, 350), 'minus_b'), ('+b*', (0, -350), 'plus_b')): curves = cmds.listRelatives( cmds.textCurves(f='Arial Black Bold', t=label)[0]) mesh = cmds.polyUnite( *[cmds.planarSrf(x, ch=False, o=True, po=1) for x in curves], ch=False)[0] cmds.xform(mesh, cp=True) cmds.xform(mesh, translation=(0, 0, 0), absolute=True) cmds.makeIdentity(cube, apply=True, t=True, r=True, s=True) cmds.select(mesh) cmds.polyColorPerVertex(rgb=(0, 0, 0), cdo=True) set_attributes({ '{0}.translateX'.format(mesh): position[0], '{0}.translateZ'.format(mesh): position[1], '{0}.rotateX'.format(mesh): -90, '{0}.scaleX'.format(mesh): 50, '{0}.scaleY'.format(mesh): 50, '{0}.scaleY'.format(mesh): 50, '{0}.overrideEnabled'.format(mesh): True, '{0}.overrideDisplayType'.format(mesh): 2 }) cmds.delete(cmds.listRelatives(curves, parent=True)) cmds.makeIdentity(mesh, apply=True, t=True, r=True, s=True) mesh = cmds.rename(mesh, name) cmds.parent(mesh, group) cube = cmds.rename(cube, 'grid') cmds.parent(cube, group) cmds.rename(group, 'Lab_coordinates_system_representation') return True
def Lab_coordinates_system_representation(): """ Creates a *CIE L\\*a\\*b\\** coordinates system representation. Returns ------- bool Definition success. """ group = cmds.createNode('transform') cube = cmds.polyCube(w=600, h=100, d=600, sx=12, sy=2, sz=12, ch=False)[0] set_attributes({'{0}.translateY'.format(cube): 50, '{0}.overrideEnabled'.format(cube): True, '{0}.overrideDisplayType'.format(cube): 2, '{0}.overrideShading'.format(cube): False}) cmds.makeIdentity(cube, apply=True, t=True, r=True, s=True) cmds.select(['{0}.f[0:167]'.format(cube), '{0}.f[336:359]'.format(cube)]) cmds.delete() cmds.nurbsToPolygonsPref(polyType=1, chordHeightRatio=0.975) for label, position, name in (('-a*', (-350, 0), 'minus_a'), ('+a*', (350, 0), 'plus_a'), ('-b*', (0, 350), 'minus_b'), ('+b*', (0, -350), 'plus_b')): curves = cmds.listRelatives( cmds.textCurves(f='Arial Black Bold', t=label)[0]) mesh = cmds.polyUnite(*[cmds.planarSrf(x, ch=False, o=True, po=1) for x in curves], ch=False)[0] cmds.xform(mesh, cp=True) cmds.xform(mesh, translation=(0, 0, 0), absolute=True) cmds.makeIdentity(cube, apply=True, t=True, r=True, s=True) cmds.select(mesh) cmds.polyColorPerVertex(rgb=(0, 0, 0), cdo=True) set_attributes({'{0}.translateX'.format(mesh): position[0], '{0}.translateZ'.format(mesh): position[1], '{0}.rotateX'.format(mesh): -90, '{0}.scaleX'.format(mesh): 50, '{0}.scaleY'.format(mesh): 50, '{0}.scaleY'.format(mesh): 50, '{0}.overrideEnabled'.format(mesh): True, '{0}.overrideDisplayType'.format(mesh): 2}) cmds.delete(cmds.listRelatives(curves, parent=True)) cmds.makeIdentity(mesh, apply=True, t=True, r=True, s=True) mesh = cmds.rename(mesh, name) cmds.parent(mesh, group) cube = cmds.rename(cube, 'grid') cmds.parent(cube, group) cmds.rename(group, 'Lab_coordinates_system_representation') return True
def createUI(name='NAMEINGERFACE', size=10.0, texto='no name'): grp = 'FACE_UI_GRP' if not cmds.objExists(grp): grp = cmds.group(n=grp, em=True) if not cmds.objExists(name + '_UI_ZTR'): ztr = cmds.group(n=name + '_UI_ZTR', em=True) shape = cmds.curve(n=name + '_UI_TRF', d=1, p=[(1, -1, 0), (1, 1, 0), (-1, 1, 0), (-1, -1, 0), (1, -1, 0)]) cnt = cmds.circle(n=name + '_UI_CNT', nr=[0, 0, 1], radius=0.3)[0] cmds.transformLimits(cnt, tx=(-1, 1), ty=(-1, 1), etx=(True, True), ety=(True, True)) changeColor([shape], 2) changeColor([cnt], 22) try: text = cmds.textCurves(n=name + '_UI_TCV', f='Arial', t=texto) cmds.move(0, size / 2.0, 0, text, absolute=True) except: pass cmds.parent(ztr, grp) cmds.parent(shape, ztr) cmds.parent(cnt, shape) cmds.setAttr(str(shape) + '.scaleX', size) cmds.setAttr(str(shape) + '.scaleY', size) cmds.setAttr(str(shape) + '.scaleZ', size) transfomrs = [ 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v', 'tx', 'ty' ] for a in transfomrs[0:7]: cmds.setAttr(str(cnt) + '.' + a, lock=True, keyable=False, channelBox=False) for a in transfomrs: cmds.setAttr(str(shape) + '.' + a, lock=True, keyable=False, channelBox=False) cmds.select(ztr) else: cmds.warning('Eliga otro nombre para la interface porfavor, ' + name + ' ya existe.')
def createFaceCTRLS(charName): createBoxControl('L_Brow_CTRL_'+charName) createBoxControl('R_Brow_CTRL_'+charName) mc.setAttr('R_Brow_CTRL_'+charName+'_limitBox.tx',-2.1) createBoxControl('L_Eye_CTRL_'+charName) mc.setAttr('L_Eye_CTRL_'+charName+'_limitBox.ty',-2.5) createBoxControl('R_Eye_CTRL_'+charName) mc.setAttr('R_Eye_CTRL_'+charName+'_limitBox.ty',-2.5) mc.setAttr('R_Eye_CTRL_'+charName+'_limitBox.tx',-2.1) createBoxControl('C_Mouth_CTRL_'+charName) mc.setAttr('C_Mouth_CTRL_'+charName+'_limitBox.ty',-6.25) mc.setAttr('C_Mouth_CTRL_'+charName+'_limitBox.tx',-1.05) mc.setAttr('C_Mouth_CTRL_'+charName+'_limitBox.sx',2) mc.setAttr('C_Mouth_CTRL_'+charName+'_limitBox.sx',2) mc.curve(d=1,p=[[-3.5,1.5,0],[1.5,1.5,0],[1.5,-9,0],[-3.5,-9,0],[-3.5,1.5,0]],n='Face_CTRL_'+charName) mc.textCurves(t=charName,n=charName+'text') mc.setAttr(charName+'textShape.tx',-3.5) mc.setAttr(charName+'textShape.ty',1.5) mc.parent('L_Brow_CTRL_'+charName+'_limitBox','R_Brow_CTRL_'+charName+'_limitBox','L_Eye_CTRL_'+charName+'_limitBox','R_Eye_CTRL_'+charName+'_limitBox', 'C_Mouth_CTRL_'+charName+'_limitBox',charName+'textShape','Face_CTRL_'+charName)
def text_curve(): """ ----------------------------------------------------------------------------------------------------- This function creates a set of curves of a text on a single transform node :return: ----------------------------------------------------------------------------------------------------- """ # Query the input text and assign it to a variable text = mc.textField("textCurve_text", query=True, text=True) if text: if text.startswith(" "): mc.warning("Please make sure text doesn't start with a space.") else: # Create text curves and rename it to remove "Shape" from its name crv = mc.textCurves(text=text, constructionHistory=False, name="%s_text_crv" % text)[0] crv = mc.rename(crv, crv.split("Shape")[0]) # List all the children of the created text curve children = mc.listRelatives(crv, allDescendents=True, type="transform") # List the children that has shape nodes curves = [ child for child in children if mc.listRelatives(child, shapes=True) ] # Parent the curves to crv transform node for curve in curves: mc.parent(curve, crv) mc.makeIdentity(curve, apply=True, translate=True) # Add the shape nodes to transform node and hide them in the outliner curves.append(crv) mc.select(curves) shape_add() shape_show() mc.delete( mc.listRelatives(crv, allDescendents=True, type="transform")) # Center the pivot of the transform node and snap it back in the origin mc.xform(crv, centerPivots=True) pivot = mc.xform(crv, query=True, rotatePivot=True) mc.move(-pivot[0], -pivot[1], -pivot[2], crv) mc.makeIdentity(crv, apply=True, translate=True) else: mc.warning("Please input text.")
def cvCharacter(self, ctrlType, ctrlName, r=1, d=1, dir="+Y", rot=(0, 0, 0), *args): """ Create and return a curve to be used as a control. """ # get radius by checking linear unit r = self.dpCheckLinearUnit(r) curve = self.cvControl(ctrlType, ctrlName, r, d, dir, rot) # edit a minime curve: cmds.addAttr(curve, longName="rigScale", attributeType='float', defaultValue=1, keyable=True) cmds.addAttr(curve, longName="rigScaleMultiplier", attributeType='float', defaultValue=1, keyable=False) # create Option_Ctrl Text: try: optCtrlTxt = cmds.group(name="Option_Ctrl_Txt", empty=True) try: cvText = cmds.textCurves(name="Option_Ctrl_Txt_TEMP_Grp", font="Source Sans Pro", text="Option Ctrl", constructionHistory=False)[0] except: cvText = cmds.textCurves(name="Option_Ctrl_Txt_TEMP_Grp", font="Arial", text="Option Ctrl", constructionHistory=False)[0] txtShapeList = cmds.listRelatives(cvText, allDescendents=True, type='nurbsCurve') if txtShapeList: for s, shape in enumerate(txtShapeList): # store CV world position curveCVList = cmds.getAttr(shape+'.cp', multiIndices=True) vtxWorldPosition = [] for i in curveCVList : cvPointPosition = cmds.xform(shape+'.cp['+str(i)+']', query=True, translation=True, worldSpace=True) vtxWorldPosition.append(cvPointPosition) # parent the shapeNode : cmds.parent(shape, optCtrlTxt, r=True, s=True) # restore the shape world position for i in curveCVList: cmds.xform(shape+'.cp['+str(i)+']', a=True, worldSpace=True, t=vtxWorldPosition[i]) cmds.rename(shape, optCtrlTxt+"Shape"+str(s)) cmds.delete(cvText) cmds.parent(optCtrlTxt, curve) cmds.setAttr(optCtrlTxt+".template", 1) cmds.setAttr(optCtrlTxt+".tx", -0.72*r) cmds.setAttr(optCtrlTxt+".ty", 1.1*r) except: # it will pass if we don't able to find the font to create the text pass return curve
def text(t = "foo", font="Droid Sans", hipoly = False, cleanup = True): #note: hipoly mode seems to generate a couple weird extra vertices in the final output. obj1 = mc.textCurves( f=font,t=t) obj2 = mc.planarSrf(obj1) if hipoly: obj3 = nurbsToPoly() else: obj3 = mel.eval("nurbsToPoly -mnd 1 -ch 1 -f 1 -pt 1 -pc 500 -chr 0.9 -ft 0.7787 -mel 1 -d 0.196 -ut 1 -un 3 -vt 1 -vn 3 -uch 0 -ucr 0 -cht 0.01 -es 0 -ntr 0 -mrt 0 -uss 1 \"" + obj2[0] + "\";") if cleanup: d([obj1,obj2]) mc.xform(obj3[0], cp=True) return obj3
def setNurbsTxt(*args):#romain truchard 2017 #1-create text--- fontName = cmds.optionMenu(fontOptionMenu, q=True, value=True)#query selected font nameFormat = ("\"" + fontName + "\"")#add quotation marks to selected font nurbsTextFieldValue = cmds.textField(nurbsTextField, query=True, text=True)#get user input tempCurveTxt = cmds.textCurves(font=nameFormat, text=nurbsTextFieldValue, name="txtTemp")#create textCurves with correct font #2-merge the curves--- cmds.select(r=True, hi=True)#select everything : transform shpes etc curSel = cmds.ls(sl=True) #put everything in array shapes = cmds.ls(curSel, shapes=True)#put all shapes in array transforms = cmds.ls(curSel, transforms=True)#put all transforms in array tempGrp = cmds.group(em=True, n="grpTemp")#create empty group to put all shapes cmds.select(transforms)#select all transforms cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=0) cmds.select(shapes)#select all shapes cmds.select(tempGrp, add=True)#add empty group to selection cmds.parent(r=True, s=True)#parent -r -s (merge curves in empty group) finalText = cmds.rename("grpTemp", nurbsTextFieldValue)#rename group with user input cmds.select(transforms[0])#select remaining transforms cmds.delete()#delete them cmds.select(finalText) boundingBox = cmds.xform(finalText, query=True, bb=True) halfOfXboundingBox = boundingBox[3] / 2 cmds.xform(finalText, ws=True, piv=[halfOfXboundingBox, 0, 0]) worldPosition = cmds.xform(finalText, q=True, piv=True, ws=True) cmds.xform(finalText, translation=(-worldPosition[0],-worldPosition[1],-worldPosition[2])) cmds.FreezeTransformations(finalText)
def create_text(text, font): print(font) if font == '': cmds.textCurves(ch=0, t=text, font=default_font) else: cmds.textCurves(ch=0, t=text, font=font) cmds.ungroup() cmds.ungroup() curves = cmds.ls(sl=True) cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=0) shapes = curves[1:] cmds.select(shapes, r=True) cmds.pickWalk(d='Down') cmds.select(curves[0], tgl=True) cmds.parent(r=True, s=True) cmds.pickWalk(d='up') cmds.delete(shapes) cmds.xform(cp=True) cmds.rename(text.lower() + "_crv") return cmds.ls(sl=True)[0] print(' ') # Clear Warnings
def text(self, text='text'): ''' Create text control object @param text: Text string @type: str ''' # Check text string if not text: raise Exception('Empty string error!') # Create Text #textCurve = mc.textCurves(ch=False,f='Arial',t=text) textCurve = mc.textCurves(ch=False, f='Utopia-Bold', t=text) # Parent shapes to single treansform textShapes = mc.ls(mc.listRelatives(textCurve, ad=True), type='nurbsCurve') for textShape in textShapes: textXform = mc.listRelatives(textShape, p=True)[0] textXform = mc.parent(textXform, w=True) mc.makeIdentity(textXform, apply=True, t=True, r=True, s=True, n=False) mc.parent(textShape, textCurve, r=True, s=True) mc.delete(textXform) # Delete unused transforms textChildren = mc.listRelatives(textCurve, c=True, type='transform') if textChildren: mc.delete(textChildren) # Position text mc.select(textCurve) mm.eval('CenterPivot') piv = mc.xform(textCurve, q=True, ws=True, rp=True) mc.move(-piv[0], -piv[1], -piv[2], textCurve, ws=True, r=True) # Scale text width = (mc.getAttr(textCurve[0] + '.boundingBoxMaxX') - mc.getAttr(textCurve[0] + '.boundingBoxMinX')) height = (mc.getAttr(textCurve[0] + '.boundingBoxMaxY') - mc.getAttr(textCurve[0] + '.boundingBoxMinY')) if width > height: sc = 1.0 / width else: sc = 1.0 / height mc.scale(sc, sc, sc, textCurve) # Freeze Transforms mc.makeIdentity(textCurve, apply=True, t=True, r=True, s=True, n=False) # Return result return textCurve
def text(t="foo", font="Droid Sans", hipoly=False, cleanup=True): #note: hipoly mode seems to generate a couple weird extra vertices in the final output. obj1 = mc.textCurves(f=font, t=t) obj2 = mc.planarSrf(obj1) if hipoly: obj3 = nurbsToPoly() else: obj3 = mel.eval( "nurbsToPoly -mnd 1 -ch 1 -f 1 -pt 1 -pc 500 -chr 0.9 -ft 0.7787 -mel 1 -d 0.196 -ut 1 -un 3 -vt 1 -vn 3 -uch 0 -ucr 0 -cht 0.01 -es 0 -ntr 0 -mrt 0 -uss 1 \"" + obj2[0] + "\";") if cleanup: d([obj1, obj2]) mc.xform(obj3[0], cp=True) return obj3
def makeWords(self, mostCommon, font='Comic Sans MS'): """ Function to make the text curves of the three most common words Function to go through the list of the most common used words and order them from greatest to least, the most common starting on top. """ for i in range(0, len(mostCommon)): curves = mc.textCurves(n="word{0}".format(1), f=font, t=mostCommon[i][0], ch=True) mc.setAttr(curves[0] + ".translateY", (len(mostCommon) - i) * 0.5) mc.select(ne=True) mc.planarSrf(n="Trim Char {0}".format(curves), ko=False, d=1, po=1)
def text(self, text="text"): """ Create text control object @param text: Text string @type: str """ # Check text string if not text: raise Exception("Empty string error!") # Create Text # textCurve = mc.textCurves(ch=False,f='Arial',t=text) textCurve = mc.textCurves(ch=False, f="Utopia-Bold", t=text) # Parent shapes to single treansform textShapes = mc.ls(mc.listRelatives(textCurve, ad=True), type="nurbsCurve") for textShape in textShapes: textXform = mc.listRelatives(textShape, p=True)[0] textXform = mc.parent(textXform, w=True) mc.makeIdentity(textXform, apply=True, t=True, r=True, s=True, n=False) mc.parent(textShape, textCurve, r=True, s=True) mc.delete(textXform) # Delete unused transforms textChildren = mc.listRelatives(textCurve, c=True, type="transform") if textChildren: mc.delete(textChildren) # Position text mc.select(textCurve) mm.eval("CenterPivot") piv = mc.xform(textCurve, q=True, ws=True, rp=True) mc.move(-piv[0], -piv[1], -piv[2], textCurve, ws=True, r=True) # Scale text width = mc.getAttr(textCurve[0] + ".boundingBoxMaxX") - mc.getAttr(textCurve[0] + ".boundingBoxMinX") height = mc.getAttr(textCurve[0] + ".boundingBoxMaxY") - mc.getAttr(textCurve[0] + ".boundingBoxMinY") if width > height: sc = 1.0 / width else: sc = 1.0 / height mc.scale(sc, sc, sc, textCurve) # Freeze Transforms mc.makeIdentity(textCurve, apply=True, t=True, r=True, s=True, n=False) # Return result return textCurve
def text(self, text='text'): """ Create text control object @param text: Text string @type: str """ # Check text string if not text: raise Exception('Empty string error!') # Create Text # textCurve = cmds.textCurves(ch=False,f='Arial',t=text) textCurve = cmds.textCurves(ch=False, f='Utopia-Bold', t=text) # Parent shapes to single treansform textShapes = cmds.ls(cmds.listRelatives(textCurve, ad=True), type='nurbsCurve') for textShape in textShapes: textXform = cmds.listRelatives(textShape, p=True)[0] textXform = cmds.parent(textXform, w=True) cmds.makeIdentity(textXform, apply=True, t=True, r=True, s=True, n=False) cmds.parent(textShape, textCurve, r=True, s=True) cmds.delete(textXform) # Delete unused transforms textChildren = cmds.listRelatives(textCurve, c=True, type='transform') if textChildren: cmds.delete(textChildren) # Position text cmds.select(textCurve) mel.eval('CenterPivot') piv = cmds.xform(textCurve, q=True, ws=True, rp=True) cmds.move(-piv[0], -piv[1], -piv[2], textCurve, ws=True, r=True) # Scale text width = (cmds.getAttr(textCurve[0] + '.boundingBoxMaxX') - cmds.getAttr(textCurve[0] + '.boundingBoxMinX')) height = (cmds.getAttr(textCurve[0] + '.boundingBoxMaxY') - cmds.getAttr(textCurve[0] + '.boundingBoxMinY')) if width > height: sc = 1.0 / width else: sc = 1.0 / height cmds.scale(sc, sc, sc, textCurve) # Freeze Transforms cmds.makeIdentity(textCurve, apply=True, t=True, r=True, s=True, n=False) # Return result return textCurve
def testNurbsCurveGrpReadWrite(self): # test w/r of simple Nurbs Curve self.__files.append(util.expandFileName("testStaticNurbsCurves.abc")) testNurbsCurveRW(self, False, self.__files[-1], "haka") self.__files.append(util.expandFileName("testStaticNurbsCurveGrp.abc")) testNurbsCurveRW(self, True, self.__files[-1], "haka") # test if some curves have different degree or close states information MayaCmds.file(new=True, force=True) name = MayaCmds.textCurves(font="Courier", text="Maya") MayaCmds.addAttr(name[0], longName="riCurves", at="bool", dv=True) self.__files.append(util.expandFileName("testStaticNurbsCurveGrp2.abc")) MayaCmds.AbcExport(j="-root %s -f %s" % (name[0], self.__files[-1])) MayaCmds.AbcImport(self.__files[-1], mode="open") if "riCurves" in MayaCmds.listAttr(name[0]): self.fail(name[0] + ".riCurves shouldn't exist")
def testNurbsCurveGrpReadWrite(self): # test w/r of simple Nurbs Curve self.__files.append(util.expandFileName('testStaticNurbsCurves.abc')) testNurbsCurveRW(self, False, self.__files[-1], 'haka') self.__files.append(util.expandFileName('testStaticNurbsCurveGrp.abc')) testNurbsCurveRW(self, True, self.__files[-1], 'haka') # test if some curves have different degree or close states information MayaCmds.file(new=True, force=True) name = MayaCmds.textCurves(font='Courier', text='Maya') MayaCmds.closeCurve( name[0], replaceOriginal=True ) MayaCmds.addAttr(name[0], longName='riCurves', at='bool', dv=True) self.__files.append(util.expandFileName('testStaticNurbsCurveGrp2.abc')) MayaCmds.AbcExport(j='-root %s -f %s' % (name[0], self.__files[-1])) MayaCmds.AbcImport(self.__files[-1], mode='open') if 'riCurves' in MayaCmds.listAttr(name[0]): self.fail(name[0]+".riCurves shouldn't exist")
def testNurbsCurveGrpReadWrite(self): # test w/r of simple Nurbs Curve self.__files.append(util.expandFileName('testStaticNurbsCurves.abc')) testNurbsCurveRW(self, False, self.__files[-1], 'haka') self.__files.append(util.expandFileName('testStaticNurbsCurveGrp.abc')) testNurbsCurveRW(self, True, self.__files[-1], 'haka') # test if some curves have different degree or close states information MayaCmds.file(new=True, force=True) name = MayaCmds.textCurves(font='Courier', text='Maya') MayaCmds.addAttr(name[0], longName='riCurves', at='bool', dv=True) self.__files.append( util.expandFileName('testStaticNurbsCurveGrp2.abc')) MayaCmds.AbcExport(j='-root %s -f %s' % (name[0], self.__files[-1])) MayaCmds.AbcImport(self.__files[-1], mode='open') if 'riCurves' in MayaCmds.listAttr(name[0]): self.fail(name[0] + ".riCurves shouldn't exist")
def text(self, Name, sign=False): curveTextName = rig.textCurves(n='T_' + Name + '_Text', t=Name, o=True)[0] rig.xform(curveTextName, cp=True) childObj = rig.listRelatives(curveTextName, c=True, ad=True) rig.delete( rig.listConnections(rig.listRelatives(curveTextName, c=True)[0], s=True, d=False)[0]) rig.move(0, 0, 0, curveTextName, rpr=True) rig.setAttr(curveTextName + '.ry', 180) rig.setAttr(curveTextName + '.rx', -90) rig.makeIdentity(curveTextName, apply=True, s=True, r=True, t=True) TransObj = rig.ls(childObj, type='transform') for i, obj in enumerate(TransObj): rig.rename(obj, 'T_' + Name + '_' + str(i) + '_C') if sign: rig.setAttr(curveTextName + '.overrideEnabled', 1) rig.setAttr(curveTextName + '.overrideDisplayType', 2) return curveTextName
def showAllNumbers(self): "Method to apply number on each vertex (for debugging only...)" for i in range(self.numPoints): txt = cmds.textCurves(text=str(i)) cmds.scale(.5,.5,.5) cmds.move(self.vertices[i][0], self.vertices[i][1], self.vertices[i][2], txt)
def sqCreateStickyLipsCtrlAttr(self, *args): if not cmds.objExists(self.optionCtrl): cmds.circle(name=self.optionCtrl, constructionHistory=False) cmds.addAttr(self.optionCtrl, longName='stickyLips', attributeType='bool') cmds.setAttr(self.optionCtrl+'.stickyLips', edit=True, keyable=True) for i in range(0, self.maxIter): cmds.addAttr(self.optionCtrl, longName="stickyLipsWireLocator"+str(i), attributeType='float', keyable=False) for i in range(0, self.maxIter): for wireNode in self.wireNodeList: cmds.connectAttr(self.optionCtrl+".stickyLipsWireLocator"+str(i), wireNode+".wireLocatorEnvelope["+str(i)+"]") slTextCurve = cmds.textCurves(ch=False, font="Arial|w400|h-08", text="StickyLips", name="StickyLips_Label_Txt")[0] if "Shape" in slTextCurve: slTextCurve = cmds.rename(slTextCurve, slTextCurve[:slTextCurve.find("Shape")]) t = 0 slCharTransformList = cmds.listRelatives(slTextCurve, children=True, type="transform") for charTransform in slCharTransformList: txValue = cmds.getAttr(charTransform+".tx") sLTextShapeList = cmds.listRelatives(charTransform, allDescendents=True, type="nurbsCurve") for i, textShape in enumerate(sLTextShapeList): textShape = cmds.rename(textShape, "StickyLips_Txt_"+str(t)+"Shape") cmds.parent(textShape, slTextCurve, shape=True, relative=True) cmds.move(txValue, 0, 0, textShape+".cv[:]", relative=True) t = t+1 cmds.delete(charTransform) cmds.setAttr(slTextCurve+".translateX", -0.1) cmds.setAttr(slTextCurve+".translateY", 0.25) cmds.setAttr(slTextCurve+".scaleX", 0.1) cmds.setAttr(slTextCurve+".scaleY", 0.1) cmds.setAttr(slTextCurve+".scaleZ", 0.1) cmds.setAttr(slTextCurve+".template", 1) cmds.makeIdentity(slTextCurve, apply=True) sideNameList = ["L", "R"] for side in sideNameList: bg = cmds.circle(name=side+"_StickyLips_Bg", normal=(0,0,1), radius=1, degree=1, sections=4, constructionHistory=False)[0] cmds.setAttr(bg+".rotateZ", 45) cmds.setAttr(bg+".translateX", 0.5) cmds.makeIdentity(bg, apply=True) cmds.setAttr(bg+".scaleX", 0.85) cmds.setAttr(bg+".scaleY", 0.15) cmds.makeIdentity(bg, apply=True) cmds.setAttr(bg+".template", 1) self.sliderCtrl = cmds.circle(name=side+"_StickyLips_Ctrl", normal=(0,0,1), radius=0.1, degree=3, constructionHistory=False)[0] attrToHideList = ['ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'] for attr in attrToHideList: cmds.setAttr(self.sliderCtrl+"."+attr, edit=True, lock=True, keyable=False) cmds.transformLimits(self.sliderCtrl, translationX=(0,1), enableTranslationX=(1,1)) distPos = 1.0 / self.maxIter for i in range(0, self.maxIter): lPosA = (i * distPos) lPosB = (lPosA + distPos) rPosB = 1 - (i * distPos) rPosA = (rPosB - distPos) if i > 0: lPosA = lPosA - (distPos*0.33) rPosA = rPosA - (distPos*0.33) cmds.setDrivenKeyframe(self.optionCtrl, attribute="stickyLipsWireLocator"+str(i), currentDriver=sideNameList[0]+"_StickyLips_Ctrl.translateX", driverValue=lPosA, value=0, inTangentType="linear", outTangentType="linear") cmds.setDrivenKeyframe(self.optionCtrl, attribute="stickyLipsWireLocator"+str(i), currentDriver=sideNameList[0]+"_StickyLips_Ctrl.translateX", driverValue=lPosB, value=1, inTangentType="linear", outTangentType="linear") cmds.setDrivenKeyframe(self.optionCtrl, attribute="stickyLipsWireLocator"+str(i), currentDriver=sideNameList[1]+"_StickyLips_Ctrl.translateX", driverValue=rPosA, value=0, inTangentType="linear", outTangentType="linear") cmds.setDrivenKeyframe(self.optionCtrl, attribute="stickyLipsWireLocator"+str(i), currentDriver=sideNameList[1]+"_StickyLips_Ctrl.translateX", driverValue=rPosB, value=1, inTangentType="linear", outTangentType="linear") lSliderGrp = cmds.group(sideNameList[0]+"_StickyLips_Ctrl", sideNameList[0]+"_StickyLips_Bg", name=sideNameList[0]+"_StickyLips_Ctrl_Grp") rSliderGrp = cmds.group(sideNameList[1]+"_StickyLips_Ctrl", sideNameList[1]+"_StickyLips_Bg", name=sideNameList[1]+"_StickyLips_Ctrl_Grp") cmds.setAttr(rSliderGrp+".rotateZ", 180) cmds.setAttr(rSliderGrp+".translateY", -0.25) sliderGrp = cmds.group(lSliderGrp, rSliderGrp, slTextCurve, name="StickyLips_Ctrl_Grp")
def testNurbsCurveRW(self, isGroup, abcFileName, inText): MayaCmds.file(new=True, force=True) name = MayaCmds.textCurves(font="Courier", text=inText) if isGroup == True: MayaCmds.addAttr(name[0], longName="riCurves", at="bool", dv=True) shapeNames = MayaCmds.ls(type="nurbsCurve") miscinfo = [] cv = [] knot = [] curveInfoNode = MayaCmds.createNode("curveInfo") for i in range(0, len(shapeNames)): shapeName = shapeNames[i] MayaCmds.connectAttr(shapeName + ".worldSpace", curveInfoNode + ".inputCurve", force=True) controlPoints = MayaCmds.getAttr(curveInfoNode + ".controlPoints[*]") cv.append(controlPoints) numCV = len(controlPoints) spans = MayaCmds.getAttr(shapeName + ".spans") degree = MayaCmds.getAttr(shapeName + ".degree") form = MayaCmds.getAttr(shapeName + ".form") minVal = MayaCmds.getAttr(shapeName + ".minValue") maxVal = MayaCmds.getAttr(shapeName + ".maxValue") misc = [numCV, spans, degree, form, minVal, maxVal] miscinfo.append(misc) knots = MayaCmds.getAttr(curveInfoNode + ".knots[*]") knot.append(knots) MayaCmds.AbcExport(j="-root %s -f %s" % (name[0], abcFileName)) # reading test MayaCmds.AbcImport(abcFileName, mode="open") if isGroup == True: shapeNames = MayaCmds.ls(exactType="nurbsCurve") self.failUnless(MayaCmds.getAttr(name[0] + ".riCurves")) miscinfo2 = [] cv2 = [] knot2 = [] curveInfoNode = MayaCmds.createNode("curveInfo") for i in range(0, len(shapeNames)): name = shapeNames[i] MayaCmds.connectAttr(name + ".worldSpace", curveInfoNode + ".inputCurve", force=True) controlPoints = MayaCmds.getAttr(curveInfoNode + ".controlPoints[*]") cv2.append(controlPoints) numCV = len(controlPoints) spans = MayaCmds.getAttr(name + ".spans") degree = MayaCmds.getAttr(name + ".degree") form = MayaCmds.getAttr(name + ".form") minVal = MayaCmds.getAttr(name + ".minValue") maxVal = MayaCmds.getAttr(name + ".maxValue") misc = [numCV, spans, degree, form, minVal, maxVal] miscinfo2.append(misc) knots = MayaCmds.getAttr(curveInfoNode + ".knots[*]") knot2.append(knots) for i in range(0, len(shapeNames)): name = shapeNames[i] self.failUnlessEqual(len(cv[i]), len(cv2[i])) for j in range(0, len(cv[i])): cp1 = cv[i][j] cp2 = cv2[i][j] self.failUnlessAlmostEqual(cp1[0], cp2[0], 3, "curve[%d].cp[%d].x not equal" % (i, j)) self.failUnlessAlmostEqual(cp1[1], cp2[1], 3, "curve[%d].cp[%d].y not equal" % (i, j)) self.failUnlessAlmostEqual(cp1[2], cp2[2], 3, "curve[%d].cp[%d].z not equal" % (i, j))
#if tx in range(30,42): #cmds.setKeyframe( myList[temp], attribute="translateX", value=posx, t=(itr*42) + tx ) temp += 1 if temp >= listSize: temp = 0 #if tx in range(30,42): #cmds.setKeyframe( myList[temp], attribute="translateX", value=tm, t=tx ) return homeName = cmds.cameraView(camera='persp') cmds.cameraView(homeName, e=True, camera='persp', ab=True) cmds.play() waves() playCoolStuff() cmds.cameraView(homeName, e=True, camera='persp', sc=True) #just a short example that moves a cube for 120 'seconds' cmds.polyCube() cmds.setKeyframe(attribute="translateX", value=0, t=94) for x in xrange(0, 60): x += 1 cmds.setKeyframe(attribute="translateX", value=x) meme = cmds.textCurves(f='Courier', t='Meme', o=True) cmds.scale(5, 5, 5, meme, scaleXYZ=True) cmds.color(meme, rgb=(1, 0, 0))
def playCoolStuff(): xPos = 0 xPos2 = 0 zPos = 0 zPos2 = 0 yPos = 0 yPosRot = 0 yScale = 0 memeScale = 0 cmds.polyCube() cube1 = cmds.polyCube() cube2 = cmds.polyCube() cube3 = cmds.polyCube() cube4 = cmds.polyCube() cube5 = cmds.polyCube() cmds.move(-10, 0, 0) cube6 = cmds.polyCube() cmds.move(10, 0, 0) cube7 = cmds.polyCube() cmds.move(0, 0, -10) cube8 = cmds.polyCube() cmds.move(0, 0, 10) meme = cmds.textCurves(f='Courier', t='Meme', o=True) cmds.move(-13, 0, 0, meme) #cmds.scale(1,1,1,meme,scaleXYZ = True) cmds.color(meme, rgb=(1, 0, 0)) #sphere1 = cmds.polySphere() #cmds.hide(sphere1) startFrame = cmds.playbackOptions(q=True, minTime=True) endFrame = cmds.playbackOptions(q=True, maxTime=True) currentFrame = startFrame cubeList = [cube1, cube2, cube3, cube4, cube5, cube6, cube7, cube8] w = 0 curTime = cmds.currentTime(currentFrame) cmds.playbackOptions(loop="continuous", ast=2, aet=500, min=2) for x in range(100): #cmds.orbit(horizontalAngle = curTime) print currentFrame cmds.select(ado=True) tt = random.randint(-20, 20) ty = random.randint(-20, 20) tz = random.randint(-20, 20) if w <= len(cubeList): cmds.polyColorPerVertex(cubeList[w], colorRGB=[tt * .035, ty * .005, tz * .016], colorDisplayOption=True) w += 1 if w >= len(cubeList): w = 0 cmds.setKeyframe(cube1, attribute="translateX", value=xPos, t=x * 10) ##cmds.setKeyframe(cube1, attribute="rotateY", value=xPos, t=x*2 ) xPos -= 1 cmds.setKeyframe(cube2, attribute="translateX", value=xPos2, t=x * 10) ## cmds.setKeyframe(cube2, attribute="rotateY", value=xPos2, t=x*2 ) xPos2 += 1 cmds.setKeyframe(cube3, attribute="translateZ", value=zPos, t=x * 10) ## cmds.setKeyframe(cube3, attribute="rotateY", value=zPos, t=x*2 ) zPos -= 1 cmds.setKeyframe(cube4, attribute="translateZ", value=zPos2, t=x * 10) ## cmds.setKeyframe(cube4, attribute="rotateY", value=zPos2, t=x*2 ) zPos2 += 1 cmds.setKeyframe(cube1, cube2, cube3, cube4, cube5, cube6, cube7, cube8, attribute="rotateY", value=yPosRot, t=x * 10) cmds.setKeyframe(cube1, cube2, cube3, cube4, cube5, cube6, cube7, cube8, attribute="scaleX", value=1, t=x * 10) cmds.setKeyframe(cube1, cube2, cube3, cube4, cube5, cube6, cube7, cube8, attribute="scaleY", value=1, t=x * 10) cmds.setKeyframe(cube1, cube2, cube3, cube4, cube5, cube6, cube7, cube8, attribute="scaleZ", value=1, t=x * 10) cmds.setKeyframe(meme, attribute="scaleX", value=memeScale, t=x * 10) cmds.setKeyframe(meme, attribute="scaleY", value=memeScale, t=x * 10) cmds.setKeyframe(meme, attribute="scaleZ", value=memeScale, t=x * 10) currentFrame += 1 if x in range(10, 20): cmds.polyColorPerVertex(cubeList[w], colorRGB=[tt * .005, ty * .035, tz * .026], colorDisplayOption=True) xPos += 2 ##xPos+=xPos2 xPos2 -= 2 ##xPos2-=zPos zPos += 2 ##zPos+=zPos2 zPos2 -= 2 ##zPos2-=x if x in range(20, 30): cmds.polyColorPerVertex(cubeList[w], colorRGB=[tt * .005, ty * .035, tz * .026], colorDisplayOption=True) xPos -= 3 xPos2 += 3 zPos -= 3 zPos2 += 3 cmds.setKeyframe(cube5, cube6, cube7, cube8, attribute="translateY", value=yPos, t=x * 10) yPos += 2 yPosRot += 15 cmds.setKeyframe(cube5, cube6, cube7, cube8, attribute="rotateY", value=yPosRot, t=x * 10) if x in range(30, 40): yPos -= 4 cmds.setKeyframe(cube5, cube6, cube7, cube8, attribute="translateY", value=yPos, t=x * 10) if x in range(30, 40): yPosRot += 15 cmds.setKeyframe(cube5, cube6, cube7, cube8, attribute="translateY", value=yPos, t=x * 10) if x in range(40, 50): yPos += 6 yScale += .65 yPosRot += 15 memeScale += 1 cmds.setKeyframe(cube5, cube6, cube7, cube8, attribute="translateY", value=yPos, t=x * 10) cmds.setKeyframe(cube1, cube2, cube3, cube4, cube5, cube6, cube7, cube8, attribute="scaleX", value=yScale, t=x * 10) cmds.setKeyframe(cube1, cube2, cube3, cube4, cube5, cube6, cube7, cube8, attribute="scaleY", value=yScale, t=x * 10) cmds.setKeyframe(cube1, cube2, cube3, cube4, cube5, cube6, cube7, cube8, attribute="scaleZ", value=yScale, t=x * 10) cmds.setKeyframe(meme, attribute="scaleX", value=memeScale, t=x * 10) cmds.setKeyframe(meme, attribute="scaleY", value=memeScale, t=x * 10) cmds.setKeyframe(meme, attribute="scaleZ", value=memeScale, t=x * 10) return
def IKFK(*args): #Mirror Joints cmds.select ( 'L_RF_Heel', 'L_RF_Fingers', 'L_RF_Ankle', 'L_Leg_JJ', 'L_Knee_JJ', 'L_Ankle_JJ', 'L_Ball_JJ', 'L_Fingers_JJ','L_RF_Ball') HideAxis = cmds.ls( selection=True ) for jnt in HideAxis: cmds.setAttr (jnt + ".displayLocalAxis", 0) cmds.duplicate ("L_Leg_JJ", rc = True) cmds.duplicate ("L_Leg_JJ", rc = True) cmds.rename ("L_Leg_JJ1", "L_Leg_FK") cmds.rename ("L_Knee_JJ1", "L_Knee_FK") cmds.rename ("L_Ankle_JJ1", "L_Ankle_FK") cmds.rename ("L_Ball_JJ1", "L_Ball_FK") cmds.rename ("L_Fingers_JJ1", "L_Fingers_FK") cmds.rename ("L_Leg_JJ2", "L_Leg_IK") cmds.rename ("L_Knee_JJ2", "L_Knee_IK") cmds.rename ("L_Ankle_JJ2", "L_Ankle_IK") cmds.rename ("L_Ball_JJ2", "L_Ball_IK") cmds.rename ("L_Fingers_JJ2", "L_Fingers_IK") cmds.mirrorJoint ('L_Leg_JJ',mirrorYZ = True, mirrorBehavior = True, searchReplace=('L_', 'R_')) cmds.mirrorJoint ('L_RF_Heel',mirrorYZ = True, mirrorBehavior = True, searchReplace=('L_', 'R_')) cmds.mirrorJoint ('L_Leg_FK',mirrorYZ = True, mirrorBehavior = True, searchReplace=('L_', 'R_')) cmds.mirrorJoint ('L_Leg_IK',mirrorYZ = True, mirrorBehavior = True, searchReplace=('L_', 'R_')) #IK GlobalMult = cmds.floatSliderGrp (RadioControlador, q = True, value = 2) radio = GlobalMult cmds.ikHandle (n="L_LegIKrp", sj="L_Leg_IK", ee= "L_Ankle_IK", sol='ikRPsolver') cmds.ikHandle (n="L_AnkleIKsch", sj="L_Ankle_IK", ee= "L_Ball_IK", sol = 'ikSCsolver') cmds.ikHandle (n="L_BallIKsch", sj="L_Ball_IK", ee= "L_Fingers_IK", sol = 'ikSCsolver') cmds.ikHandle (n="R_LegIKrp", sj="R_Leg_IK", ee= "R_Ankle_IK", sol='ikRPsolver') cmds.ikHandle (n="R_AnkleIKsch", sj="R_Ankle_IK", ee= "R_Ball_IK", sol = 'ikSCsolver') cmds.ikHandle (n="R_BallIKsch", sj="R_Ball_IK", ee= "R_Fingers_IK", sol = 'ikSCsolver') cmds.curve(n="L_LegIK_CC" , d=1, p=[(1, 1, 1),(1,1,-1) ,(1, -1, -1) ,(1, -1, 1) ,(-1, -1, 1) ,(-1, 1, 1) ,(1, 1, 1) ,(1, -1, 1) ,(-1, -1, 1) ,(-1, -1, -1) ,(-1, 1, -1) ,(1, 1, -1) ,(1, -1, -1) ,(-1, -1, -1) ,(-1, 1, -1) ,(-1, 1, 1)], k = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]) cmds.group ("L_LegIK_CC", n= "L_LegIK_GRP") cmds.pointConstraint ("L_Ball_JJ", "L_LegIK_GRP") cmds.delete ("L_LegIK_GRP_pointConstraint1") cmds.orientConstraint ("L_Ball_JJ", "L_LegIK_GRP") cmds.delete ("L_LegIK_GRP_orientConstraint1") cmds.duplicate ('L_LegIK_CC',n='R_LegIK_CC') cmds.group ("R_LegIK_CC", n= "R_LegIK_GRP") cmds.parent ('R_LegIK_GRP', w = True) cmds.group(n = 'R_LegIK_GRP2', em = True) cmds.parent ('R_LegIK_GRP','R_LegIK_GRP2') cmds.setAttr('R_LegIK_GRP2.scaleX',-1) cmds.scale(GlobalMult,GlobalMult,GlobalMult,'L_LegIK_GRP', r = True) cmds.scale(GlobalMult,GlobalMult,GlobalMult,'R_LegIK_GRP', r = True) cmds.setAttr ("L_LegIK_CC.overrideEnabled", 1) cmds.setAttr ("R_LegIK_CC.overrideEnabled", 1) cmds.setAttr ("L_LegIK_CC.overrideColor", 6) cmds.setAttr ("R_LegIK_CC.overrideColor", 13) #FK GlobalMult = cmds.floatSliderGrp (RadioControlador, q = True, value = 2) radio = GlobalMult cmds.select ( 'L_Leg_FK', 'L_Knee_FK', 'L_Ankle_FK', 'R_Leg_FK', 'R_Knee_FK' ,'R_Ankle_FK','L_Ball_FK','R_Ball_FK') FKCircle = cmds.ls( selection=True ) for FK in FKCircle: cmds.circle (n= FK + str ('_CC'), r= radio, nr=(0, 1, 0)) cmds.group (n= FK + str ('_CC') + str ('GRP')) cmds.pointConstraint (FK, FK + str ('_CC') + str ('GRP'), mo= False) cmds.orientConstraint (FK, FK + str ('_CC') + str ('GRP'), mo= False) cmds.delete (FK + str ('_CC') + str ('GRP')+str('_pointConstraint1')) cmds.delete (FK + str ('_CC') + str ('GRP')+str('_orientConstraint1')) cmds.orientConstraint (FK + str ('_CC'),FK , mo= True) cmds.pointConstraint (FK + str ('_CC'),FK , mo= True) cmds.setAttr (FK + str ('_CC')+ str ('Shape.overrideEnabled'), 1) cmds.setAttr (FK + str ('_CC')+ str ('Shape.overrideColor'), 6) cmds.setAttr ('R_Leg_FK_CCShape.overrideColor',13) cmds.setAttr ('R_Knee_FK_CCShape.overrideColor',13) cmds.setAttr ('R_Ankle_FK_CCShape.overrideColor',13) cmds.setAttr ('R_Ball_FK_CCShape.overrideColor',13) cmds.parent ('L_Knee_FK_CCGRP','L_Leg_FK_CC') cmds.parent ('L_Ankle_FK_CCGRP','L_Knee_FK_CC') cmds.parent ('L_Ball_FK_CCGRP','L_Ankle_FK_CC') cmds.parent ('R_Knee_FK_CCGRP','R_Leg_FK_CC') cmds.parent ('R_Ankle_FK_CCGRP','R_Knee_FK_CC') cmds.parent ('R_Ball_FK_CCGRP','R_Ankle_FK_CC') #ReverseFoot cmds.parent ('L_RF_Heel','L_LegIK_CC') cmds.parent ('L_LegIKrp','L_RF_Ankle') cmds.parent ('L_AnkleIKsch','L_RF_Ball') cmds.parent ('L_BallIKsch','L_RF_Fingers') cmds.parent ('R_RF_Heel','R_LegIK_CC') cmds.parent ('R_LegIKrp','R_RF_Ankle') cmds.parent ('R_AnkleIKsch','R_RF_Ball') cmds.parent ('R_BallIKsch','R_RF_Fingers') cmds.addAttr ('L_LegIK_CC', ln= 'RollHeel', at= 'double' , dv = 0 ) cmds.setAttr ('L_LegIK_CC.RollHeel', k = True) cmds.connectAttr ('L_LegIK_CC.RollHeel','L_RF_Heel.rotateZ') cmds.addAttr ('L_LegIK_CC', ln= 'TwistHeel', at= 'double' , dv = 0 ) cmds.setAttr ('L_LegIK_CC.TwistHeel', k = True) cmds.connectAttr ('L_LegIK_CC.TwistHeel','L_RF_Heel.rotateY') cmds.addAttr ('L_LegIK_CC', ln= 'RollBall', at= 'double' , dv = 0 ) cmds.setAttr ('L_LegIK_CC.RollBall', k = True) cmds.connectAttr ('L_LegIK_CC.RollBall','L_RF_Ball.rotateZ') cmds.addAttr ('L_LegIK_CC', ln= 'TwistBall', at= 'double' , dv = 0 ) cmds.setAttr ('L_LegIK_CC.TwistBall', k = True) cmds.connectAttr ('L_LegIK_CC.TwistBall','L_RF_Ball.rotateY') cmds.addAttr ('L_LegIK_CC', ln= 'RollToe', at= 'double' , dv = 0 ) cmds.setAttr ('L_LegIK_CC.RollToe', k = True) cmds.connectAttr ('L_LegIK_CC.RollToe','L_RF_Fingers.rotateZ') cmds.addAttr ('R_LegIK_CC', ln= 'RollHeel', at= 'double' , dv = 0 ) cmds.setAttr ('R_LegIK_CC.RollHeel', k = True) cmds.connectAttr ('R_LegIK_CC.RollHeel','R_RF_Heel.rotateZ') cmds.addAttr ('R_LegIK_CC', ln= 'TwistHeel', at= 'double' , dv = 0 ) cmds.setAttr ('R_LegIK_CC.TwistHeel', k = True) cmds.connectAttr ('R_LegIK_CC.TwistHeel','R_RF_Heel.rotateY') cmds.addAttr ('R_LegIK_CC', ln= 'RollBall', at= 'double' , dv = 0 ) cmds.setAttr ('R_LegIK_CC.RollBall', k = True) cmds.connectAttr ('R_LegIK_CC.RollBall','R_RF_Ball.rotateZ') cmds.addAttr ('R_LegIK_CC', ln= 'TwistBall', at= 'double' , dv = 0 ) cmds.setAttr ('R_LegIK_CC.TwistBall', k = True) cmds.connectAttr ('R_LegIK_CC.TwistBall','R_RF_Ball.rotateY') cmds.addAttr ('R_LegIK_CC', ln= 'RollToe', at= 'double' , dv = 0 ) cmds.setAttr ('R_LegIK_CC.RollToe', k = True) cmds.connectAttr ('R_LegIK_CC.RollToe','R_RF_Fingers.rotateZ') #Pole Vector cmds.polyPlane (n="LLeg_PV_Plane", sh = 1, sw= 1) cmds.delete ("LLeg_PV_Plane.vtx[3]") cmds.cluster ("LLeg_PV_Plane.vtx[0]", n= "LegCluster") cmds.cluster ("LLeg_PV_Plane.vtx[1]" ,n= "KneeCluster") cmds.cluster ("LLeg_PV_Plane.vtx[2]", n= "AnkleCluster") cmds.pointConstraint ("L_Leg_JJ","LegClusterHandle") cmds.pointConstraint ("L_Knee_JJ","KneeClusterHandle") cmds.pointConstraint ("L_Ankle_JJ","AnkleClusterHandle") P01X = cmds.getAttr("L_Leg_JJ.translateX") P01Y = cmds.getAttr("L_Leg_JJ.translateY") P01Z = cmds.getAttr("L_Leg_JJ.translateZ") P02X = cmds.getAttr("L_Knee_JJ.translateX") + P01X P02Y = cmds.getAttr("L_Knee_JJ.translateY") + P01Y P02Z = cmds.getAttr("L_Knee_JJ.translateZ") + P01Z P03X = cmds.getAttr("L_Ankle_JJ.translateX") + P02X P03Y = cmds.getAttr("L_Ankle_JJ.translateY") + P02Y P03Z = cmds.getAttr("L_Ankle_JJ.translateZ") + P02Z P04X = cmds.getAttr("L_Fingers_JJ.translateX") + P03X P04Y = cmds.getAttr("L_Fingers_JJ.translateY") + P03Y P04Z = cmds.getAttr("L_Fingers_JJ.translateZ") + P03Z cmds.moveVertexAlongDirection ("LLeg_PV_Plane.vtx[1]", v= P02X+(P02X/2)) PVposition = cmds.pointPosition ("LLeg_PV_Plane.vtx[1]") cmds.circle (n="LLeg_PV01",nr=(0, 0, 1),r = radio/2) cmds.circle (n="LLeg_PV02",nr=(0, 1, 0),r = radio/2) cmds.circle (n="LLeg_PV03",nr=(1, 0, 0),r = radio/2) cmds.parent ("LLeg_PV02Shape","LLeg_PV01",r= True, s= True) cmds.parent ("LLeg_PV03Shape","LLeg_PV01",r= True, s= True) cmds.delete ("LLeg_PV02","LLeg_PV03") cmds.select ("LLeg_PV01") cmds.group (n= "LLeg_PV01_GRP", r= True) cmds.xform (t=PVposition) cmds.duplicate ("LLeg_PV01_GRP", n= "RLeg_PV_GRP") cmds.rename ("RLeg_PV_GRP|LLeg_PV01", "RLeg_PV01") cmds.rename ("LLeg_PV01_GRP", "LLeg_PV0_GRP") cmds.move(0, 0, 0, ".scalePivot",".rotatePivot", absolute=True) cmds.setAttr ("RLeg_PV_GRP.scaleX", -1) cmds.select ("LLeg_PV01","L_LegIKrp") cmds.PoleVectorConstraint () cmds.select ("RLeg_PV01","R_LegIKrp") cmds.PoleVectorConstraint () cmds.setAttr("RLeg_PV01Shape.overrideEnabled", True ) cmds.setAttr("RLeg_PV01Shape.overrideColor", 13 ) cmds.setAttr("RLeg_PV02Shape1.overrideEnabled", True ) cmds.setAttr("RLeg_PV02Shape1.overrideColor", 13 ) cmds.setAttr("RLeg_PV03Shape1.overrideEnabled", True ) cmds.setAttr("RLeg_PV03Shape1.overrideColor", 13 ) cmds.setAttr("LLeg_PV01Shape.overrideEnabled", True ) cmds.setAttr("LLeg_PV01Shape.overrideColor", 6 ) cmds.setAttr("LLeg_PV02Shape.overrideEnabled", True ) cmds.setAttr("LLeg_PV02Shape.overrideColor", 6 ) cmds.setAttr("LLeg_PV03Shape.overrideEnabled", True ) cmds.setAttr("LLeg_PV03Shape.overrideColor", 6 ) cmds.group ("LLeg_PV_Plane","LegClusterHandle","KneeClusterHandle","AnkleClusterHandle", n= "ExtrasAutoLegs") cmds.setAttr ("ExtrasAutoLegs.visibility", 0) #Switch IK FK if cmds.objExists ("IK_FK_CC"): print "CurveControl IKFK Exists" else: if cmds.objExists('makeTextCurves1'): cmds.rename ('makeTextCurves1','makeTextCurves1LOL') Texto = 'IK-FK' Color = 16 Text = cmds.textCurves (n= Texto, t = Texto, o = True) Lista= cmds.listRelatives (Text, ad = True) Shape = Lista[1] cmds.delete ('makeTextCurves1') for Curva in Lista: if cmds.objectType(str(Curva), isType='nurbsCurve'): curvaPapa = cmds.listRelatives(Curva, p = True) curvaAbuelo = cmds.listRelatives(curvaPapa, p = True) DobleCurva = cmds.listRelatives(curvaAbuelo) if len(DobleCurva)==2: LetrasDobles.append (Curva) else: if not Shape == curvaPapa[0]: cmds.makeIdentity (curvaAbuelo, a = True, t = True , r = True) cmds.parent (Curva, Shape, r = True, s = True) #Colores cmds.setAttr (Curva+'.overrideEnabled', 1) cmds.setAttr (Curva+'.overrideColor', Color) cmds.parent (Shape,w=True) cmds.rename(Shape, 'IK_FK_CC') cmds.setAttr ("IK_FK_CC.overrideEnabled", 1) cmds.setAttr ("IK_FK_CC.overrideColor", 16) cmds.setAttr ('IK_FK_CC.rotateX', -90) cmds.xform(cp= True) cmds.setAttr ('IK_FK_CC.scaleX', GlobalMult) cmds.setAttr ('IK_FK_CC.scaleY', GlobalMult) cmds.setAttr ('IK_FK_CC.scaleZ', GlobalMult) cmds.makeIdentity(a=True, t = True, r = True, s=True) cmds.select ("IK_FK_CC") cmds.addAttr (ln= "LeftLegIKFK", min=0, max=1) cmds.setAttr ("IK_FK_CC.LeftLegIKFK", keyable = True) cmds.select ("IK_FK_CC") cmds.addAttr (ln= "RightLegIKFK", min=0, max=1) cmds.setAttr ("IK_FK_CC.RightLegIKFK", keyable = True) cmds.expression (n="L_Leg_Switch", s = "L_Leg_JJ.rotateX = (L_Leg_FK.rotateX* IK_FK_CC.LeftLegIKFK)+( L_Leg_IK.rotateX*(1- IK_FK_CC.LeftLegIKFK)); \nL_Leg_JJ.rotateY = (L_Leg_FK.rotateY*IK_FK_CC.LeftLegIKFK)+( L_Leg_IK.rotateY*(1-IK_FK_CC.LeftLegIKFK)); \nL_Leg_JJ.rotateZ = (L_Leg_FK.rotateZ*IK_FK_CC.LeftLegIKFK)+( L_Leg_IK.rotateZ*(1-IK_FK_CC.LeftLegIKFK)); \nL_Knee_JJ.rotateX = (L_Knee_FK.rotateX*IK_FK_CC.LeftLegIKFK)+( L_Knee_IK.rotateX*(1-IK_FK_CC.LeftLegIKFK)); \nL_Knee_JJ.rotateY = (L_Knee_FK.rotateY*IK_FK_CC.LeftLegIKFK)+( L_Knee_IK.rotateY*(1-IK_FK_CC.LeftLegIKFK)); \nL_Knee_JJ.rotateZ = (L_Knee_FK.rotateZ*IK_FK_CC.LeftLegIKFK)+( L_Knee_IK.rotateZ*(1-IK_FK_CC.LeftLegIKFK)); \nL_Ankle_JJ.rotateX = (L_Ankle_FK.rotateX*IK_FK_CC.LeftLegIKFK)+( L_Ankle_IK.rotateX*(1-IK_FK_CC.LeftLegIKFK)); \nL_Ankle_JJ.rotateY = (L_Ankle_FK.rotateY*IK_FK_CC.LeftLegIKFK)+( L_Ankle_IK.rotateY*(1-IK_FK_CC.LeftLegIKFK)); \nL_Ankle_JJ.rotateZ = (L_Ankle_FK.rotateZ*IK_FK_CC.LeftLegIKFK)+( L_Ankle_IK.rotateZ*(1-IK_FK_CC.LeftLegIKFK)); \nL_Ball_JJ.rotateX = (L_Ball_FK.rotateX*IK_FK_CC.LeftLegIKFK)+( L_Ball_IK.rotateX*(1-IK_FK_CC.LeftLegIKFK)); \nL_Ball_JJ.rotateY = (L_Ball_FK.rotateY*IK_FK_CC.LeftLegIKFK)+( L_Ball_IK.rotateY*(1-IK_FK_CC.LeftLegIKFK)); \nL_Ball_JJ.rotateZ = (L_Ball_FK.rotateZ*IK_FK_CC.LeftLegIKFK)+( L_Ball_IK.rotateZ*(1-IK_FK_CC.LeftLegIKFK)); \nL_Fingers_JJ.rotateX = (L_Fingers_FK.rotateX*IK_FK_CC.LeftLegIKFK)+( L_Fingers_IK.rotateX*(1-IK_FK_CC.LeftLegIKFK)); \nL_Fingers_JJ.rotateY = (L_Fingers_FK.rotateY*IK_FK_CC.LeftLegIKFK)+( L_Fingers_IK.rotateY*(1-IK_FK_CC.LeftLegIKFK)); \nL_Fingers_JJ.rotateZ = (L_Fingers_FK.rotateZ*IK_FK_CC.LeftLegIKFK)+( L_Fingers_IK.rotateZ*(1-IK_FK_CC.LeftLegIKFK)); \n \nL_Leg_JJ.translateX = (L_Leg_FK.translateX* IK_FK_CC.LeftLegIKFK)+( L_Leg_IK.translateX*(1- IK_FK_CC.LeftLegIKFK)); \nL_Leg_JJ.translateY = (L_Leg_FK.translateY*IK_FK_CC.LeftLegIKFK)+( L_Leg_IK.translateY*(1-IK_FK_CC.LeftLegIKFK)); \nL_Leg_JJ.translateZ = (L_Leg_FK.translateZ*IK_FK_CC.LeftLegIKFK)+( L_Leg_IK.translateZ*(1-IK_FK_CC.LeftLegIKFK)); \nL_Knee_JJ.translateX = (L_Knee_FK.translateX*IK_FK_CC.LeftLegIKFK)+( L_Knee_IK.translateX*(1-IK_FK_CC.LeftLegIKFK)); \nL_Knee_JJ.translateY = (L_Knee_FK.translateY*IK_FK_CC.LeftLegIKFK)+( L_Knee_IK.translateY*(1-IK_FK_CC.LeftLegIKFK)); \nL_Knee_JJ.translateZ = (L_Knee_FK.translateZ*IK_FK_CC.LeftLegIKFK)+( L_Knee_IK.translateZ*(1-IK_FK_CC.LeftLegIKFK)); \nL_Ankle_JJ.translateX = (L_Ankle_FK.translateX*IK_FK_CC.LeftLegIKFK)+( L_Ankle_IK.translateX*(1-IK_FK_CC.LeftLegIKFK)); \nL_Ankle_JJ.translateY = (L_Ankle_FK.translateY*IK_FK_CC.LeftLegIKFK)+( L_Ankle_IK.translateY*(1-IK_FK_CC.LeftLegIKFK)); \nL_Ankle_JJ.translateZ = (L_Ankle_FK.translateZ*IK_FK_CC.LeftLegIKFK)+( L_Ankle_IK.translateZ*(1-IK_FK_CC.LeftLegIKFK)); \nL_Ball_JJ.translateX = (L_Ball_FK.translateX*IK_FK_CC.LeftLegIKFK)+( L_Ball_IK.translateX*(1-IK_FK_CC.LeftLegIKFK)); \nL_Ball_JJ.translateY = (L_Ball_FK.translateY*IK_FK_CC.LeftLegIKFK)+( L_Ball_IK.translateY*(1-IK_FK_CC.LeftLegIKFK)); \nL_Ball_JJ.translateZ = (L_Ball_FK.translateZ*IK_FK_CC.LeftLegIKFK)+( L_Ball_IK.translateZ*(1-IK_FK_CC.LeftLegIKFK)); \nL_Fingers_JJ.translateX = (L_Fingers_FK.translateX*IK_FK_CC.LeftLegIKFK)+( L_Fingers_IK.translateX*(1-IK_FK_CC.LeftLegIKFK)); \nL_Fingers_JJ.translateY = (L_Fingers_FK.translateY*IK_FK_CC.LeftLegIKFK)+( L_Fingers_IK.translateY*(1-IK_FK_CC.LeftLegIKFK)); \nL_Fingers_JJ.translateZ = (L_Fingers_FK.translateZ*IK_FK_CC.LeftLegIKFK)+( L_Fingers_IK.translateZ*(1-IK_FK_CC.LeftLegIKFK)); \n \n \nL_Leg_FK_CC.visibility = IK_FK_CC.LeftLegIKFK; \nL_LegIK_CC.visibility = (1-IK_FK_CC.LeftLegIKFK); \nLLeg_PV01.visibility = (1-IK_FK_CC.LeftLegIKFK);" ) cmds.expression (n="R_Leg_Switch", s = "R_Leg_JJ.rotateX = (R_Leg_FK.rotateX* IK_FK_CC.LeftLegIKFK)+( R_Leg_IK.rotateX*(1- IK_FK_CC.LeftLegIKFK)); \nR_Leg_JJ.rotateY = (R_Leg_FK.rotateY*IK_FK_CC.LeftLegIKFK)+( R_Leg_IK.rotateY*(1-IK_FK_CC.LeftLegIKFK)); \nR_Leg_JJ.rotateZ = (R_Leg_FK.rotateZ*IK_FK_CC.LeftLegIKFK)+( R_Leg_IK.rotateZ*(1-IK_FK_CC.LeftLegIKFK)); \nR_Knee_JJ.rotateX = (R_Knee_FK.rotateX*IK_FK_CC.LeftLegIKFK)+( R_Knee_IK.rotateX*(1-IK_FK_CC.LeftLegIKFK)); \nR_Knee_JJ.rotateY = (R_Knee_FK.rotateY*IK_FK_CC.LeftLegIKFK)+( R_Knee_IK.rotateY*(1-IK_FK_CC.LeftLegIKFK)); \nR_Knee_JJ.rotateZ = (R_Knee_FK.rotateZ*IK_FK_CC.LeftLegIKFK)+( R_Knee_IK.rotateZ*(1-IK_FK_CC.LeftLegIKFK)); \nR_Ankle_JJ.rotateX = (R_Ankle_FK.rotateX*IK_FK_CC.LeftLegIKFK)+( R_Ankle_IK.rotateX*(1-IK_FK_CC.LeftLegIKFK)); \nR_Ankle_JJ.rotateY = (R_Ankle_FK.rotateY*IK_FK_CC.LeftLegIKFK)+( R_Ankle_IK.rotateY*(1-IK_FK_CC.LeftLegIKFK)); \nR_Ankle_JJ.rotateZ = (R_Ankle_FK.rotateZ*IK_FK_CC.LeftLegIKFK)+( R_Ankle_IK.rotateZ*(1-IK_FK_CC.LeftLegIKFK)); \nR_Ball_JJ.rotateX = (R_Ball_FK.rotateX*IK_FK_CC.LeftLegIKFK)+( R_Ball_IK.rotateX*(1-IK_FK_CC.LeftLegIKFK)); \nR_Ball_JJ.rotateY = (R_Ball_FK.rotateY*IK_FK_CC.LeftLegIKFK)+( R_Ball_IK.rotateY*(1-IK_FK_CC.LeftLegIKFK)); \nR_Ball_JJ.rotateZ = (R_Ball_FK.rotateZ*IK_FK_CC.LeftLegIKFK)+( R_Ball_IK.rotateZ*(1-IK_FK_CC.LeftLegIKFK)); \nR_Fingers_JJ.rotateX = (R_Fingers_FK.rotateX*IK_FK_CC.LeftLegIKFK)+( R_Fingers_IK.rotateX*(1-IK_FK_CC.LeftLegIKFK)); \nR_Fingers_JJ.rotateY = (R_Fingers_FK.rotateY*IK_FK_CC.LeftLegIKFK)+( R_Fingers_IK.rotateY*(1-IK_FK_CC.LeftLegIKFK)); \nR_Fingers_JJ.rotateZ = (R_Fingers_FK.rotateZ*IK_FK_CC.LeftLegIKFK)+( R_Fingers_IK.rotateZ*(1-IK_FK_CC.LeftLegIKFK)); \n \nR_Leg_JJ.translateX = (R_Leg_FK.translateX* IK_FK_CC.LeftLegIKFK)+( R_Leg_IK.translateX*(1- IK_FK_CC.LeftLegIKFK)); \nR_Leg_JJ.translateY = (R_Leg_FK.translateY*IK_FK_CC.LeftLegIKFK)+( R_Leg_IK.translateY*(1-IK_FK_CC.LeftLegIKFK)); \nR_Leg_JJ.translateZ = (R_Leg_FK.translateZ*IK_FK_CC.LeftLegIKFK)+( R_Leg_IK.translateZ*(1-IK_FK_CC.LeftLegIKFK)); \nR_Knee_JJ.translateX = (R_Knee_FK.translateX*IK_FK_CC.LeftLegIKFK)+( R_Knee_IK.translateX*(1-IK_FK_CC.LeftLegIKFK)); \nR_Knee_JJ.translateY = (R_Knee_FK.translateY*IK_FK_CC.LeftLegIKFK)+( R_Knee_IK.translateY*(1-IK_FK_CC.LeftLegIKFK)); \nR_Knee_JJ.translateZ = (R_Knee_FK.translateZ*IK_FK_CC.LeftLegIKFK)+( R_Knee_IK.translateZ*(1-IK_FK_CC.LeftLegIKFK)); \nR_Ankle_JJ.translateX = (R_Ankle_FK.translateX*IK_FK_CC.LeftLegIKFK)+( R_Ankle_IK.translateX*(1-IK_FK_CC.LeftLegIKFK)); \nR_Ankle_JJ.translateY = (R_Ankle_FK.translateY*IK_FK_CC.LeftLegIKFK)+( R_Ankle_IK.translateY*(1-IK_FK_CC.LeftLegIKFK)); \nR_Ankle_JJ.translateZ = (R_Ankle_FK.translateZ*IK_FK_CC.LeftLegIKFK)+( R_Ankle_IK.translateZ*(1-IK_FK_CC.LeftLegIKFK)); \nR_Ball_JJ.translateX = (R_Ball_FK.translateX*IK_FK_CC.LeftLegIKFK)+( R_Ball_IK.translateX*(1-IK_FK_CC.LeftLegIKFK)); \nR_Ball_JJ.translateY = (R_Ball_FK.translateY*IK_FK_CC.LeftLegIKFK)+( R_Ball_IK.translateY*(1-IK_FK_CC.LeftLegIKFK)); \nR_Ball_JJ.translateZ = (R_Ball_FK.translateZ*IK_FK_CC.LeftLegIKFK)+( R_Ball_IK.translateZ*(1-IK_FK_CC.LeftLegIKFK)); \nR_Fingers_JJ.translateX = (R_Fingers_FK.translateX*IK_FK_CC.LeftLegIKFK)+( R_Fingers_IK.translateX*(1-IK_FK_CC.LeftLegIKFK)); \nR_Fingers_JJ.translateY = (R_Fingers_FK.translateY*IK_FK_CC.LeftLegIKFK)+( R_Fingers_IK.translateY*(1-IK_FK_CC.LeftLegIKFK)); \nR_Fingers_JJ.translateZ = (R_Fingers_FK.translateZ*IK_FK_CC.LeftLegIKFK)+( R_Fingers_IK.translateZ*(1-IK_FK_CC.LeftLegIKFK)); \n \n \nR_Leg_FK_CC.visibility = IK_FK_CC.RightLegIKFK; \nR_LegIK_CC.visibility = (1-IK_FK_CC.RightLegIKFK); \nRLeg_PV01.visibility = (1-IK_FK_CC.RightLegIKFK);" ) # Grouping and Organizing cmds.group ('L_Leg_JJ', 'L_Leg_FK', 'L_Leg_IK ','L_Leg_FK_CCGRP', n = 'L_Leg_Joints') cmds.group ('R_Leg_JJ', 'R_Leg_FK', 'R_Leg_IK ','R_Leg_FK_CCGRP', n = 'R_Leg_Joints') cmds.group ("L_LegIK_GRP", "LLeg_PV0_GRP", n="L_IKLeg_GRP") cmds.group ("R_LegIK_GRP", "RLeg_PV_GRP", n="R_IKLeg_GRP") cmds.group ("L_IKLeg_GRP", "R_IKLeg_GRP",'L_Leg_Joints','R_Leg_Joints',n= "Connect this to the rest of the rig") cmds.group ('ExtrasAutoLegs',"Connect_this_to_the_rest_of_the_rig", n="RdM_AutoLEGS" ) cmds.select ('L_Ball_JJ', 'L_Ankle_JJ', 'L_Knee_JJ', 'L_Leg_JJ','R_Ball_JJ', 'R_Leg_JJ', 'R_Knee_JJ', 'R_Ankle_JJ') cmds.sets (n= 'BindThisToLegs') cmds.delete('R_LegIK_GRP2') #Locking Attr #FK cmds.select ('R_Leg_FK_CC','R_Knee_FK_CC','R_Ankle_FK_CC','R_Ball_FK_CC','L_Leg_FK_CC','L_Knee_FK_CC','L_Ankle_FK_CC','L_Ball_FK_CC') FK = cmds.ls(sl=True) for T in FK: cmds.setAttr(str(T)+'.translateX',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.translateY',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.translateZ',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.scaleX',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.scaleY',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.scaleZ',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.visibility',lock = True, keyable = False, channelBox = False) #IK, Clavicule cmds.select ('L_LegIK_CC', 'R_LegIK_CC') IK = cmds.ls(sl=True) for T in IK: cmds.setAttr(str(T)+'.scaleX',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.scaleY',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.scaleZ',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.visibility',lock = True, keyable = False, channelBox = False) #Pole Vector cmds.select ('LLeg_PV01', 'RLeg_PV01') PV = cmds.ls(sl=True) for T in PV: cmds.setAttr(str(T)+'.rotateX',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.rotateY',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.rotateZ',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.scaleX',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.scaleY',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.scaleZ',lock = True, keyable = False, channelBox = False) cmds.setAttr(str(T)+'.visibility',lock = True, keyable = False, channelBox = False) print ('Legs DONE')
def missing_folders(): project_path = project_path_base + '/' + project_name assets_path = project_path + '/prod/assets/' asset_type = os.listdir(assets_path) asset_name = [] asset_list = [] for each in asset_type: asset_path = assets_path + each + '/' print(asset_path) asset_name.append(asset_path) print(asset_name) for each in asset_name: assets = os.listdir(each) for each in assets: asset_list.append(each) print(asset_list) for typ in asset_type: print(typ) path = assets_path + typ folders = ['mod', 'rig', 'export', 'lookdev', 'zbrush'] for each in os.listdir(path): state_path = path + '/' + each states = os.listdir(state_path) print('states == > ' + str(state_path)) missing_folders_count = 0 for folder in folders: if not folder in states: missing_folders_count += 1 print(each + ' has no ' + folder + ' folder') #go_on = mc.confirmDialog(title='Missing Folders !', message = 'There are ' + str(missing_folders_count) + ' folders missing in ' + str(len(os.listdir(path))) + ' assets, create them ?', button =['Yes','No'], defaultButton='Yes', cancelButton='No', dismissString='No') #if go_on == 'Yes': mkfolder.cr_folder(state_path + '\\' + folder, 777) if folder == 'rig': mkfolder.cr_folder( state_path + '\\' + folder + '\\V000', 777) mc.file(new=True, f=True) mc.textCurves(f='Arial|wt:75|sz:100|sl:n|st:100', t=each) mc.file(rename=state_path + '\\rig\\V000\\' + 'rig') mc.file(save=True, type='mayaAscii') if folder == 'lookdev': mkfolder.cr_folder( state_path + '\\' + folder + '\\guerilla', 777) mkfolder.cr_folder( state_path + '\\' + folder + '\\mari', 777) mkfolder.cr_folder( state_path + '\\' + folder + '\\textures', 777)
######## FK jnt ######## dupFK = cmds.duplicate(ikJntSel[0], rc=1) for each in dupFK: jntNameFK = each.replace('IK_drv1', 'FK_drv') newFK = cmds.rename(each, jntNameFK) cmds.select(newFK, add=1) fkJntSel = cmds.ls(sl=1) cmds.parent(ikJntSel[0], jntGrp, a=1) cmds.parent(fkJntSel[0], jntGrp, a=1) ######## IK/FK SWITCH CONTROLLER ######## ###### create ikFk controller ###### text = cmds.textCurves(ch=0, f='Times New Roman', t='IkFk') for each in range(1, 5): cmds.rename('curve%s' % each, 'ikFk_crv%s' % each) cmds.select(text, hi=1) crvHrc = cmds.ls('*crv*', s=0) crvShape = crvHrc[4:8] crv = crvHrc[0:4] for each in crvShape[1:4]: cmds.parent(each, crv[0], r=1, s=1) cmds.move(1.4, 0, 0, crvShape[1] + '.cv[*]', r=1, os=1, ws=1) cmds.move(3.7, 0, 0, crvShape[2] + '.cv[*]', r=1, os=1, ws=1) cmds.move(6.1, 0, 0, crvShape[3] + '.cv[*]', r=1, os=1, ws=1)
def testNurbsCurveRW( self, isGroup, abcFileName, inText): MayaCmds.file(new=True, force=True) name = MayaCmds.textCurves( font='Courier', text=inText ) if isGroup == True : MayaCmds.addAttr(name[0], longName='riCurves', at='bool', dv=True) shapeNames = MayaCmds.ls(type='nurbsCurve') miscinfo=[] cv=[] knot=[] curveInfoNode = MayaCmds.createNode('curveInfo') for i in range(0, len(shapeNames)) : shapeName = shapeNames[i] MayaCmds.connectAttr(shapeName+'.worldSpace', curveInfoNode+'.inputCurve', force=True) controlPoints = MayaCmds.getAttr(curveInfoNode + '.controlPoints[*]') cv.append(controlPoints) numCV = len(controlPoints) spans = MayaCmds.getAttr(shapeName+'.spans') degree = MayaCmds.getAttr(shapeName+'.degree') form = MayaCmds.getAttr(shapeName+'.form') minVal = MayaCmds.getAttr(shapeName+'.minValue') maxVal = MayaCmds.getAttr(shapeName+'.maxValue') misc = [numCV, spans, degree, form, minVal, maxVal] miscinfo.append(misc) knots = MayaCmds.getAttr(curveInfoNode + '.knots[*]') knot.append(knots) MayaCmds.AbcExport(j='-root %s -f %s' % (name[0], abcFileName)) # reading test MayaCmds.AbcImport(abcFileName, mode='open') if isGroup == True: shapeNames = MayaCmds.ls(exactType='nurbsCurve') self.failUnless(MayaCmds.getAttr(name[0]+'.riCurves')) miscinfo2 = [] cv2 = [] knot2 = [] curveInfoNode = MayaCmds.createNode('curveInfo') for i in range(0, len(shapeNames)): name = shapeNames[i] MayaCmds.connectAttr(name+'.worldSpace', curveInfoNode+'.inputCurve', force=True) controlPoints = MayaCmds.getAttr(curveInfoNode + '.controlPoints[*]') cv2.append(controlPoints) numCV = len(controlPoints) spans = MayaCmds.getAttr(name+'.spans') degree = MayaCmds.getAttr(name+'.degree') form = MayaCmds.getAttr(name+'.form') minVal = MayaCmds.getAttr(name+'.minValue') maxVal = MayaCmds.getAttr(name+'.maxValue') misc = [numCV, spans, degree, form, minVal, maxVal] miscinfo2.append(misc) knots = MayaCmds.getAttr(curveInfoNode + '.knots[*]') knot2.append(knots) for i in range(0, len(shapeNames)) : name = shapeNames[i] self.failUnlessEqual(len(cv[i]), len(cv2[i])) for j in range(0, len(cv[i])) : cp1 = cv[i][j] cp2 = cv2[i][j] self.failUnlessAlmostEqual(cp1[0], cp2[0], 3, 'curve[%d].cp[%d].x not equal' % (i,j)) self.failUnlessAlmostEqual(cp1[1], cp2[1], 3, 'curve[%d].cp[%d].y not equal' % (i,j)) self.failUnlessAlmostEqual(cp1[2], cp2[2], 3, 'curve[%d].cp[%d].z not equal' % (i,j))
def seq(lo_num=''): if lo_num == '': result = mc.promptDialog(title='Create a Sequence', message='Sequence Number:', button=['OK', 'Cancel'], defaultButton='OK', cancelButton='Cancel', dismissString='Cancel') if result == 'OK': lo_num = mc.promptDialog(query=True, text=True) else: sys.exit('Layout Creation Aborted !') lo_num = int(lo_num) if not isinstance(lo_num, (int, long)): sys.exit retval = os.getcwd() print "Working directory is : %s" % retval os.chdir(project_path_base) retval = os.getcwd() print "Working directory changed to : %s" % retval project_path = project_path_base + '/' + project_name if not os.path.exists(project_path): print 'No Project Found !' layout_path = project_path + '/prod/seq/' layout_name = padding_numbers.padder(lo_num, 5) if os.path.exists(layout_path + layout_name): print(layout_name + ' already exists !') sys.exit('Sequence name already existing.') print(layout_name) os.mkdir(layout_path + layout_name) # create folders os.mkdir(layout_path + layout_name + '/layout') os.mkdir(layout_path + layout_name + '/layout/V000') os.mkdir(layout_path + layout_name + '/playblasts') os.mkdir(layout_path + layout_name + '/export') # create cloth folder os.mkdir(layout_path + layout_name + '/cloth') # create lookdev folder os.mkdir(layout_path + layout_name + '/lookdev') os.mkdir(layout_path + layout_name + '/lookdev/guerilla') os.mkdir(layout_path + layout_name + '/lookdev/textures') # create shots folder os.mkdir(layout_path + layout_name + '/shots') print('Sequence ' + str(lo_num) + ' successfully created !') mc.file(new=True, f=True) mc.textCurves(f='Arial|wt:75|sz:100|sl:n|st:100', t=layout_name) mc.file(rename=layout_path + layout_name + '/layout/V000/' + 'layout') # create groups for assets chars_grp = mc.group(em=True, n='chars') props_grp = mc.group(em=True, n='props') sets_grp = mc.group(em=True, n='sets') cam_grp = mc.group(em=True, n='cams') building_grp = mc.group(em=True, n='building') grps = [chars_grp, props_grp, sets_grp, building_grp, cam_grp] for grp in grps: mc.setAttr(grp + '.inheritsTransform', 0) mc.setAttr(grp + '.tx', lock=True) mc.setAttr(grp + '.ty', lock=True) mc.setAttr(grp + '.tz', lock=True) mc.setAttr(grp + '.rx', lock=True) mc.setAttr(grp + '.ry', lock=True) mc.setAttr(grp + '.rz', lock=True) mc.setAttr(grp + '.sx', lock=True) mc.setAttr(grp + '.sy', lock=True) mc.setAttr(grp + '.sz', lock=True) mc.file(save=True, type='mayaAscii')
def testAnimNCurvesDeleteReload(self): # create some animated curves MayaCmds.textCurves(ch=False, t='Maya', name='Curves', font='Courier') MayaCmds.currentTime(1, update=True) MayaCmds.select('curve1.cv[0:27]', 'curve2.cv[0:45]', 'curve3.cv[0:15]', 'curve4.cv[0:19]', 'curve5.cv[0:45]', 'curve6.cv[0:15]', replace=True) MayaCmds.setKeyframe() MayaCmds.currentTime(24, update=True) MayaCmds.select('curve1.cv[0:27]', replace=True) MayaCmds.move(-3, 3, 0, relative=True) MayaCmds.select('curve2.cv[0:45]', 'curve3.cv[0:15]', replace=True) MayaCmds.scale(1.5, 1.5, 1.5, relative=True) MayaCmds.select('curve4.cv[0:19]', replace=True) MayaCmds.move(1.5, 0, 0, relative=True) MayaCmds.rotate(0, 90, 0, relative=True) MayaCmds.select('curve5.cv[0:45]', 'curve6.cv[0:15]', replace=True) MayaCmds.move(3, 0, 0, relative=True) MayaCmds.select('curve1.cv[0:27]', 'curve2.cv[0:45]', 'curve3.cv[0:15]', 'curve4.cv[0:19]', 'curve5.cv[0:45]', 'curve6.cv[0:15]', replace=True) MayaCmds.setKeyframe() # write them out to an Abc file and load back in self.__files.append(util.expandFileName('testNCurvesReload.abc')) MayaCmds.AbcExport(j='-fr 1 24 -root CurvesShape -file ' + self.__files[-1]) # load back the Abc file, delete the 2nd letter and save to a maya file MayaCmds.AbcImport(self.__files[-1], mode='open') # delete letter "a" which has two curves MayaCmds.delete('Char_a_1') self.__files.append(util.expandFileName('test.mb')) MayaCmds.file(rename=self.__files[-1]) MayaCmds.file(save=True) # import the saved maya file to compare with the original scene MayaCmds.file(self.__files[-1], open=True) MayaCmds.select('CurvesShape', replace=True) MayaCmds.group(name='ReloadGrp') MayaCmds.AbcImport(self.__files[-2], mode='import') curveList = MayaCmds.ls(type='nurbsCurve') self.failUnlessEqual(len(curveList), 10) # test the equality of curves curves = [('|CurvesShape|Char_M_1|curve1|curveShape1', '|ReloadGrp|CurvesShape|Char_M_1|curve1|curveShape1'), ('|CurvesShape|Char_y_1|curve4|curveShape4', '|ReloadGrp|CurvesShape|Char_y_1|curve4|curveShape4'), ('|CurvesShape|Char_a_2|curve5|curveShape5', '|ReloadGrp|CurvesShape|Char_a_2|curve5|curveShape5'), ('|CurvesShape|Char_a_2|curve6|curveShape6', '|ReloadGrp|CurvesShape|Char_a_2|curve6|curveShape6')] for c in curves: for t in range(1, 25): MayaCmds.currentTime(t, update=True) if not util.compareNurbsCurve(c[0], c[1]): self.fail('%s and %s are not the same at frame %d' % (c[0], c[1], t))
def addLabel(self, x, y, z, label): cmds.textCurves(f="Times New Roman|h-4|w400|c0",t=label) cmds.xform(ro=(270,180,0), t=(x, z, y) )
def testNurbsCurveRW(self, isGroup, abcFileName, inText): MayaCmds.file(new=True, force=True) name = MayaCmds.textCurves(font='Courier', text=inText) if isGroup == True: MayaCmds.addAttr(name[0], longName='riCurves', at='bool', dv=True) shapeNames = MayaCmds.ls(type='nurbsCurve') miscinfo = [] cv = [] knot = [] curveInfoNode = MayaCmds.createNode('curveInfo') for i in range(0, len(shapeNames)): shapeName = shapeNames[i] MayaCmds.connectAttr(shapeName + '.worldSpace', curveInfoNode + '.inputCurve', force=True) controlPoints = MayaCmds.getAttr(curveInfoNode + '.controlPoints[*]') cv.append(controlPoints) numCV = len(controlPoints) spans = MayaCmds.getAttr(shapeName + '.spans') degree = MayaCmds.getAttr(shapeName + '.degree') form = MayaCmds.getAttr(shapeName + '.form') minVal = MayaCmds.getAttr(shapeName + '.minValue') maxVal = MayaCmds.getAttr(shapeName + '.maxValue') misc = [numCV, spans, degree, form, minVal, maxVal] miscinfo.append(misc) knots = MayaCmds.getAttr(curveInfoNode + '.knots[*]') knot.append(knots) MayaCmds.AbcExport(j='-root %s -f %s' % (name[0], abcFileName)) # reading test MayaCmds.AbcImport(abcFileName, mode='open') if isGroup == True: shapeNames = MayaCmds.ls(exactType='nurbsCurve') self.failUnless(MayaCmds.getAttr(name[0] + '.riCurves')) miscinfo2 = [] cv2 = [] knot2 = [] curveInfoNode = MayaCmds.createNode('curveInfo') for i in range(0, len(shapeNames)): name = shapeNames[i] MayaCmds.connectAttr(name + '.worldSpace', curveInfoNode + '.inputCurve', force=True) controlPoints = MayaCmds.getAttr(curveInfoNode + '.controlPoints[*]') cv2.append(controlPoints) numCV = len(controlPoints) spans = MayaCmds.getAttr(name + '.spans') degree = MayaCmds.getAttr(name + '.degree') form = MayaCmds.getAttr(name + '.form') minVal = MayaCmds.getAttr(name + '.minValue') maxVal = MayaCmds.getAttr(name + '.maxValue') misc = [numCV, spans, degree, form, minVal, maxVal] miscinfo2.append(misc) knots = MayaCmds.getAttr(curveInfoNode + '.knots[*]') knot2.append(knots) for i in range(0, len(shapeNames)): name = shapeNames[i] self.failUnlessEqual(len(cv[i]), len(cv2[i])) for j in range(0, len(cv[i])): cp1 = cv[i][j] cp2 = cv2[i][j] self.failUnlessAlmostEqual(cp1[0], cp2[0], 3, 'curve[%d].cp[%d].x not equal' % (i, j)) self.failUnlessAlmostEqual(cp1[1], cp2[1], 3, 'curve[%d].cp[%d].y not equal' % (i, j)) self.failUnlessAlmostEqual(cp1[2], cp2[2], 3, 'curve[%d].cp[%d].z not equal' % (i, j))
def testAnimNCurveGrpDeleteReload(self): # create an animated curves group MayaCmds.textCurves(ch=False, t='haka', name='Curves', font='Courier') MayaCmds.addAttr(longName='riCurves', at='bool', dv=True) MayaCmds.currentTime(1, update=True) MayaCmds.select('curve1.cv[0:27]', 'curve2.cv[0:45]', 'curve3.cv[0:15]', 'curve4.cv[0:19]', 'curve5.cv[0:45]', 'curve6.cv[0:15]', replace=True) MayaCmds.setKeyframe() MayaCmds.currentTime(24, update=True) MayaCmds.select('curve1.cv[0:27]', replace=True) MayaCmds.move(-3, 3, 0, relative=True) MayaCmds.select('curve2.cv[0:45]', 'curve3.cv[0:15]', replace=True) MayaCmds.scale(1.5, 1.5, 1.5, relative=True) MayaCmds.select('curve4.cv[0:19]', replace=True) MayaCmds.move(1.5, 0, 0, relative=True) MayaCmds.rotate(0, 90, 0, relative=True) MayaCmds.select('curve5.cv[0:45]', 'curve6.cv[0:15]', replace=True) MayaCmds.move(3, 0, 0, relative=True) MayaCmds.select('curve1.cv[0:27]', 'curve2.cv[0:45]', 'curve3.cv[0:15]', 'curve4.cv[0:19]', 'curve5.cv[0:45]', 'curve6.cv[0:15]', replace=True) MayaCmds.setKeyframe() # write them out to an Abc file and load back in self.__files.append(util.expandFileName('testNCurveGrpReload.abc')) MayaCmds.AbcExport(j='-fr 1 24 -root CurvesShape -file ' + self.__files[-1]) # load back the Abc file, delete the 2nd letter and save to a maya file MayaCmds.AbcImport(self.__files[-1], mode='open') # delete letter "a" which has two curves, but as a curve group. # the curve shapes are renamed under the group node MayaCmds.delete('CurvesShape1') MayaCmds.delete('CurvesShape2') self.__files.append(util.expandFileName('testCurves.mb')) MayaCmds.file(rename=self.__files[-1]) MayaCmds.file(save=True) # import the saved maya file to compare with the original scene MayaCmds.file(self.__files[-1], open=True) MayaCmds.select('|CurvesShape', replace=True) MayaCmds.group(name='ReloadGrp') MayaCmds.AbcImport(self.__files[-2], mode='import') curveList = MayaCmds.ls(type='nurbsCurve') self.failUnlessEqual(len(curveList), 10) curves = [('|CurvesShape|CurvesShape', '|ReloadGrp|CurvesShape|CurvesShape'), ('|CurvesShape|CurvesShape8', '|ReloadGrp|CurvesShape|CurvesShape3'), ('|CurvesShape|CurvesShape9', '|ReloadGrp|CurvesShape|CurvesShape4'), ('|CurvesShape|CurvesShape10', '|ReloadGrp|CurvesShape|CurvesShape5')] for c in curves: for t in range(1, 25): MayaCmds.currentTime(t, update=True) if not util.compareNurbsCurve(c[0], c[1]): self.fail('%s and %s are not the same at frame %d' % (c[0], c[1], t))
def install(self, projectName, assetType, assetName, description, artist): #======================================================================= # MASTER CONTROLS #======================================================================= #======================================================================= # build master groups #======================================================================= for group in [self.nodes['masterGroup'], self.nodes['geoGroup'], self.nodes['rigGroup'], self.nodes['controlGroup'], self.nodes['jointGroup'], self.nodes['bindGroup'], self.nodes['deformerGroup'], self.nodes['spaceGroup']]: cmds.group(empty=True, name=group) #======================================================================= # INFO #======================================================================= cmds.addAttr(self.nodes['masterGroup'], ln='project', dt='string') cmds.addAttr(self.nodes['masterGroup'], ln='assetType', dt='string') cmds.addAttr(self.nodes['masterGroup'], ln='assetName', dt='string') cmds.addAttr(self.nodes['masterGroup'], ln='artist', dt='string') cmds.addAttr(self.nodes['masterGroup'], ln='version', at='float', dv = 1) cmds.setAttr(self.nodes['masterGroup'] +".project", projectName, type='string') cmds.setAttr(self.nodes['masterGroup'] +".assetType", assetType, type='string') cmds.setAttr(self.nodes['masterGroup'] +".assetName", assetName, type='string') cmds.setAttr(self.nodes['masterGroup'] +".artist", artist, type='string') #======================================================================= # parent groups #======================================================================= cmds.parent(self.nodes['geoGroup'], self.nodes['rigGroup'], self.nodes['masterGroup']) cmds.parent(self.nodes['controlGroup'], self.nodes['jointGroup'], self.nodes['bindGroup'], self.nodes['spaceGroup'], self.nodes['deformerGroup'], self.nodes['rigGroup']) #=============================================================================== # CUSTOM ATTRIBUTE #=============================================================================== customAttribute = cmds.textCurves(ch=False, font="Arial", text=assetName)[0] shapes = cmds.listRelatives(customAttribute, ad=True, type="shape"), cmds.xform(customAttribute, cp=True) cmds.move(0,0,0, customAttribute, rpr=True) cmds.makeIdentity(customAttribute, apply=True, t=True, r=True, s=True) for s in shapes: cmds.parent(s, customAttribute, s=True, r=True) cmds.delete(cmds.listRelatives(customAttribute, ad=True, type="transform")) cmds.rename(customAttribute, self.nodes['customAttribute']) cmds.addAttr(self.nodes['customAttribute'], at="double", ln="globalScale", minValue=0.01, dv=1, k=True) cmds.connectAttr(self.nodes['customAttribute'] + '.scaleY', self.nodes['customAttribute'] + '.scaleX') cmds.connectAttr(self.nodes['customAttribute'] + '.scaleY', self.nodes['customAttribute'] + '.scaleZ') cmds.setAttr(self.nodes['customAttribute'] + '.scaleY', keyable = False , channelBox=False) cmds.setAttr(self.nodes['customAttribute'] + '.translateY', keyable = False , channelBox=False) utils_transforms.lockAndHide(self.nodes['customAttribute'], ['translateX' , 'translateZ', 'rotate', 'scaleX', 'scaleZ', 'visibility']) #======================================================================= # add displayType enum #======================================================================= for group in [self.nodes['geoGroup'], self.nodes['rigGroup'], self.nodes['controlGroup'], self.nodes['jointGroup'], self.nodes['bindGroup'], self.nodes['deformerGroup']]: attrName = group.replace("_grp", "_display") enumName = "on:template:reference:off" cmds.addAttr(self.nodes['masterGroup'], ln=attrName, at='enum', enumName = enumName, k=True) cmds.setAttr(self.nodes['masterGroup'] + "." + attrName, k=False, cb=True) cmds.setAttr(group + ".overrideEnabled", 1) cmds.connectAttr(self.nodes['masterGroup'] + "." + attrName, group + ".overrideDisplayType") condition = cmds.createNode('condition', name=attrName + "_vis_condition") cmds.connectAttr(self.nodes['masterGroup'] + "." + attrName, condition+".firstTerm") cmds.setAttr(condition+".secondTerm", 3) #off cmds.setAttr(condition+".colorIfTrueR", 0) cmds.setAttr(condition+".colorIfFalseR", 1) cmds.connectAttr(condition + ".outColorR", group + ".visibility") #======================================================================= # GLOBAL AND LOCAL CONTROLS #======================================================================= #GLOBAL self.createMasterCtrl(self.nodes['globalControl'], self.nodes['globalOffsetControl'], 'circle', 11, 0.95) cmds.parent(self.nodes['globalControl'], self.nodes['controlGroup']) #LOCAL self.createMasterCtrl(self.nodes['localControl'], self.nodes['localOffsetControl'], 'arrowCircle', 10, 0.55) cmds.parent(self.nodes['localControl'], self.nodes['globalOffsetControl']) #======================================================================= # FINALIZE #======================================================================= #======================================================================= # parent custom attr to local ctrl #======================================================================= cmds.parent(self.nodes['customAttribute'], self.nodes['localOffsetControl'], absolute=True) #======================================================================= # connect global scale #======================================================================= for obj in [self.nodes['localControl'], self.nodes['jointGroup'], self.nodes['bindGroup'], self.nodes['spaceGroup']]: cmds.connectAttr(self.nodes['customAttribute']+".globalScale", obj + ".scaleX") cmds.connectAttr(self.nodes['customAttribute']+".globalScale", obj + ".scaleY") cmds.connectAttr(self.nodes['customAttribute']+".globalScale", obj + ".scaleZ") #======================================================================= # lock and hide attributes #======================================================================= for group in [self.nodes['masterGroup'], self.nodes['geoGroup'], self.nodes['rigGroup'], self.nodes['controlGroup'], self.nodes['jointGroup'], self.nodes['bindGroup'], self.nodes['deformerGroup'], self.nodes['spaceGroup']]: utils_transforms.lockAndHide(group, ['translate', 'rotate', 'scale', 'visibility']) return
def make_tex(*args): tex = [] for x in args: x = cmds.textCurves( ch=False, f="Arial|w400|h-11", t=x) tex.append(x) return tex