def version(): filename = mc.file(q=True, sn=True) charvalue = filename.split('/') # Verifier que l'on est dans le projet if not project_name in charvalue: sys.exit('You are not working in the Project !!') # fait un thumbnail create.thumbnail() # Sortir l'emplacement du dossier de version seulement file_path = charvalue[:-2] filepath = '/'.join(file_path) path_versions = os.listdir(filepath) file_path = '/'.join(charvalue) filevalue = path_versions[-1] indexing = filevalue.split('V') indexing = int(indexing[-1]) indexing += 1 indexing = padding_numbers.padder(indexing, pad) filevalue = 'V' + str(indexing) file_type, extension = ext.get_ext(charvalue[-1]) charvalue.pop(-1) charvalue.pop(-1) charvalue.append(filevalue) charvalue = '/'.join(charvalue) os.mkdir(charvalue) charvalue = charvalue + '/' + file_type new_name = charvalue + '.' + extension mc.file(rename=new_name) mc.file(save=True, type='mayaAscii') print('version number ' + str(indexing) + ' created !') mc.warning('version number ' + str(indexing) + ' created !') return new_name
def version(): fm = mc.FileManager filename = fm.GetFileNameAndPath() charvalue = filename.split('\\') # Verifier que l'on est dans le projet if not project_name in charvalue: sys.exit('You are not working in the Project !!') # Sortir l'emplacement du dossier de version seulement file_path = charvalue[:-2] filepath = '\\'.join(file_path) path_versions = os.listdir(filepath) file_path = '\\'.join(charvalue) filevalue = path_versions[-1] indexing = filevalue.split('V') indexing = int(indexing[-1]) indexing += 1 indexing = padding_numbers.padder(indexing, pad) filevalue = 'V' + str(indexing) file_type, extension = ext.get_ext(charvalue[-1]) charvalue.pop(-1) charvalue.pop(-1) charvalue.append(filevalue) charvalue = '\\'.join(charvalue) os.mkdir(charvalue) charvalue = charvalue + '\\' + file_type + '.' + extension print(charvalue) fm.Save(charvalue) print('version number ' + str(indexing) + ' created !') return charvalue
def export(): mx = pymxs.runtime fm = mc.FileManager asset_name = fm.GetFileNameAndPath() charvalue = asset_name.split('\\') asset_name, extension = ext.get_ext(charvalue[-1]) print(asset_name) print(charvalue) print(charvalue[-4]) if not project_name in charvalue: sys.exit('You are not working in the Project !!') go_on = mx.queryBox("You are about to export the asset " + charvalue[-4] + " to Maya. Continue ?", title='Exporting to Maya : ' + charvalue[-4]) if go_on == False: sys.exit('Export of the asset : ' + charvalue[-4] + ' aborted.') current_asset = save.folder_only() print(current_asset) temp_dir = project_dir + '\\utils\\export\\' + asset_name print(temp_dir) with open(temp_dir + '.txt', "w") as f: f.write(current_asset + '\\') f.close() temp_dir = temp_dir + '.obj' exp_maxscript = 'exportFile ("' + temp_dir + '")using:theClasses[13]' print(exp_maxscript) mc.Core.EvalMAXScript("theClasses = exporterPlugin.classes") mc.Core.EvalMAXScript(exp_maxscript) print('export still in progress...') run_maya = "Y:\\Liquefacteur\\utils\\scripts\\max\\maya_export.bat" max_maya = 'ShellLaunch "' + run_maya + '" ""' print(max_maya) mc.Core.EvalMAXScript(max_maya)
def make_playblast(hd=False, master=False): pb_wh = [1280, 720] qual = 70 overwrite = False # get folder location # verifier la sauvegarde avant de faire la creation d'un shot... filename = mc.file(q=True, sn=True) charvalue = filename.split('/') # Verifier que l'on est dans le projet if not project_name in charvalue: sys.exit('You are not working in the Project !!') if not 'seq' in charvalue: sys.exit('This is not a sequence...') # get sequence/shot location current_shot = None current_seq = charvalue[5] shot_path = project_dir + '/prod/seq/' + current_seq if 'shots' in charvalue: current_shot = charvalue[7] shot_path += '/shots/' + current_shot # playblast location pb_path = shot_path + '/playblasts/' print(pb_path) sh_name = None # renaming the playblast file path_versions = os.listdir(pb_path) print(path_versions) if not path_versions: print('lol') else: pb_name = path_versions[-1] if 'shots' in charvalue: if not path_versions: pb_name = 'pb_000.mov' else: indexing = pb_name.split('_') filename, extension = ext.get_ext(indexing[-1]) indexing = int(filename) indexing += 1 indexing = padding_numbers.padder(indexing, pad) pb_name = 'pb_' + str(indexing) + '.' + extension sh_name = 'seq' + current_seq + '_' + 'shot' + current_shot + '.' + extension # select camera in the scene current_panel = mc.getPanel(wf=True) panel_types = mc.getPanel(typ='modelPanel') if current_panel not in panel_types: raise ValueError( 'Make a Right Click on the Viewport after you have the cam selected !' ) if 'shots' in charvalue: pb_cam = mc.ls('render__cam') current_cam = mc.lookThru(q=True) mc.lookThru(pb_cam) else: pb_cam = mc.ls(sl=True) if len(pb_cam) != 1: raise ValueError('Select one camera only !') current_shot = pb_cam[0].split('_') current_shot = current_shot[-1] child = mc.listRelatives(pb_cam[0], c=True) grand_child = mc.listRelatives(pb_cam[0] + '|' + child[0], c=True) last_child = mc.listRelatives(pb_cam[0] + '|' + child[0] + '|' + grand_child[0], c=True) pb_cam = mc.ls(pb_cam[0] + '|' + child[0] + '|' + grand_child[0] + '|' + last_child[0]) print(pb_cam) test_cam_name = pb_cam[0].split('|') if test_cam_name[-1] != 'render__cam': raise NameError('The Camera selected is not a Render Cam !') current_cam = mc.lookThru(q=True) mc.lookThru(pb_cam) if not path_versions: pb_name = 'pb__000.mov' indexing = pb_name.split('__') filename, extension = ext.get_ext(indexing[-1]) indexing = int(filename) indexing += 1 indexing = padding_numbers.padder(indexing, pad) pb_name = '__' + str(indexing) + '.' + extension pb_name = 'seq' + current_seq + '_' + 'shot' + current_shot + pb_name sh_name = 'seq' + current_seq + '_' + 'shot' + current_shot + '.' + extension if master == True: go_on = mc.confirmDialog( title='MASTERSHOT', message='Are you sure you want to make a mastershot ?', button=['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No') if go_on == 'Yes': pb_name = sh_name pb_path = project_dir + '/preprod/animatic/shotlist/' hd = True overwrite = True else: raise NameError('Master Shot creation aborted !') # virer ornements camera if not 'shots' in charvalue: pb_cam = [pb_cam[0] + '|render__cam'] print('NIQUEMOUK') mc.setAttr(pb_cam[0] + 'Shape' + '.displayGateMaskColor', 0, 0, 0) mc.setAttr(pb_cam[0] + 'Shape' + '.displayGateMaskOpacity', 1) cam_overscan = mc.getAttr(pb_cam[0] + 'Shape' + '.overscan') mc.setAttr(pb_cam[0] + 'Shape' + '.overscan', 1.0) # virer tout ce qui ne sert a rien... curves_visibility = mc.modelEditor(current_panel, q=True, nurbsCurves=True) cams_visibility = mc.modelEditor(current_panel, q=True, cameras=True) loc_visibility = mc.modelEditor(current_panel, q=True, locators=True) if curves_visibility == True: try: mc.modelEditor(current_panel, e=True, nurbsCurves=False) except: pass if cams_visibility == True: try: mc.modelEditor(current_panel, e=True, cameras=False) except: pass if loc_visibility == True: try: mc.modelEditor(current_panel, e=True, locators=False) except: pass current_sel = mc.ls(sl=True) mc.select(cl=True) # make playblast if hd == True: pb_wh = [1920, 1080] qual = 100 mc.playblast(f=pb_path + pb_name, fmt='qt', c='H.264', p=100, wh=pb_wh, orn=False, qlt=qual, fo=overwrite) mc.lookThru(current_cam) mc.setAttr(pb_cam[0] + 'Shape' + '.overscan', cam_overscan) if curves_visibility == True: try: mc.modelEditor(current_panel, e=True, nurbsCurves=True) except: pass if cams_visibility == True: try: mc.modelEditor(current_panel, e=True, cameras=True) except: pass if loc_visibility == True: try: mc.modelEditor(current_panel, e=True, locators=True) except: pass mc.select(current_sel)
try: file_path = open(temp_dir + '.txt', 'r') asset_path = file_path.read() file_path.close() asset_path = asset_path.split(';') asset_type = asset_path[-1] asset_path = asset_path[0] asset_name = asset_path.split('/') asset_name = asset_name[-1] asset_name, asset_ext = ext.get_ext(asset_name) write_path = project_dir + '/prod/assets/' + asset_type + '/' + asset_name + '/lookdev/guerilla/' a = dict({'prefixnodes':False,'containschildren':False}) rPass = pynode('RenderPass') # add a reference with Modifier() as mod: refNode, topNodes = mod.createref(asset_name + '__ref', asset_path, parent=None, options=a) refNode.setinheritedattr('Referenceable',False, False) refNode, topNodes = mod.createref('cyclo', cyclo_dir, parent=None, options=a)
def ref(asset='', nspace=':'): project_path = project_path_base + '/' + project_name + '/prod/assets' if asset == '': sys.exit('Nothing written !') asset_type = asset.split(' ') print(asset_type) for each in asset_type: each = each.lower() print('lower ?? ' + str(asset_type)) asset = asset_type[1] asset_state = asset_type[2] if not asset_type[0] in ('chars', 'props', 'sets'): sys.exit('asset type is not good. it is "chars","props" or "sets"') if len(asset_type) < 4: # lister dossiers pour chercher "master" asset_path = os.listdir(project_path + '/' + asset_type[0] + '/' + asset + '/' + asset_state) # master trouve ? demander ouverture if 'master' in asset_path: go_on = mc.confirmDialog( title='Master found for ' + asset, message='a Master file has been found for ' + asset + ', reference it ?', button=['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No') if go_on == 'No': sys.exit('Reference aborted') asset_type.append('master') # master non trouve? demander si reference de version. # dans l'ideal faire une fenetre avec liste deroulante else: result = mc.promptDialog( title='No Master file', message='No Master file found. Reference a version instead ?', button=['OK', 'Cancel'], defaultButton='OK', cancelButton='Cancel', dismissString='Cancel') if result == 'OK': txt = mc.promptDialog(query=True, text=True) asset_type.append(txt) else: sys.exit('Reference aborted') print(asset_type) asset_version = asset_type[3] asset_type = asset_type[0] asset_path = project_path + '/' + asset_type + '/' + asset + '/' + asset_state + '/' + asset_version print(asset_path) get_assets = os.listdir(asset_path) print('listdir => ' + str(get_assets)) for each in get_assets: print(each) if each == 'thumbnail.png': get_assets.remove(each) if each == 'infos.txt': get_assets.remove(each) if each == 'Thumbs.db': get_assets.remove(each) print('new get_assets => ' + str(get_assets)) asset_ext = get_assets[0] asset_name, asset_ext = extension.get_ext(asset_ext) print('test asset name et ext ===> ' + asset_name + ' ' + asset_ext) asset_path = asset_path + '/' + asset_name + '.' + asset_ext mc.file(asset_path, r=True, mergeNamespacesOnClash=True, options='v=0', namespace=nspace)
def g_abc_export(mode='currentframe', qst=0, qend=0): filename = mc.file(q=True, sn=True) charvalue = filename.split('/') # Verifier que l'on est dans le projet if not project_name in charvalue: sys.exit('You are not working in the Project !!') # Verifier asset/sequence # Definir options pour asset sequence if 'seq' in charvalue: # sequences options/variables check_name = ['chars', 'props', 'sets', 'cams', 'building'] else: # asset options/variables check_name = charvalue[-4] # Sortir l'emplacement du fichier seulement file_path = charvalue[:-1] filevalue = charvalue[-1] print('filevalue => ' + filevalue) filevalue, extension = ext.get_ext(filevalue) filevalue = charvalue[-4] file_path.pop(-1) file_path.pop(-1) print(charvalue) file_path = '/'.join(file_path) print('file_path => ' + file_path) print(filevalue) extension = '.abc' charvalue = file_path + '/' + 'export/' + filevalue + extension print(charvalue) mc.SelectAll() sel = mc.ls(sl=True) check.transforms(sel) sel = pmc.ls(sl=True) mc.select(cl=True) print(sel) # check export asset / sequence if not len(sel) == 1: print('sel > 1') # asset export checks if not 'seq' in charvalue: print('asset type') sys.exit( 'One group only must be selected, with the asset name. Use the Asset Group Builder command to do that.' ) #sequence export checks else: print('seq type') if not sel == check_name: sys.exit( 'You need to select the 5 groups that are in the asset => chars, props, sets, cams and building. Nothing else should be present.' ) # asset export checks elif not sel[0] == check_name: sys.exit( 'One group only must be selected, with the asset name. Use the Asset Group Builder command to do that.' ) if os.path.exists(charvalue): go_on = mc.confirmDialog(title='Exporting Alembic !!', message='An ABC already exists for : ' + filevalue + ', do you want to overwrite it ?', button=['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No') if go_on == 'No': sys.exit('Alembic Export Aborted') abc_custom_export(framemode=mode, qstart=qst, qend=qend, preroll=False, path=charvalue, preframe=0, nodes=sel) print('Alembic : ' + filevalue + ' successfully created !')
def g_abc_seq_export(mode='currentframe', qst=0, qend=0, check_name=['chars', 'props', 'sets', 'cams', 'building']): filename = mc.file(q=True, sn=True) charvalue = filename.split('/') # Verifier que l'on est dans le projet if not project_name in charvalue: sys.exit('You are not working in the Project !!') # Verifier asset/sequence # Definir options pour asset sequence # sequences options/variables # Sortir l'emplacement du fichier seulement file_path = charvalue[:-1] filevalue = charvalue[-1] filevalue, extension = ext.get_ext(filevalue) filevalue = charvalue[-4] file_path.pop(-1) file_path.pop(-1) file_path = '/'.join(file_path) extension = '.abc' charvalue = file_path + '/' + 'export/' mc.select(cl=True) for each in check_name: group = mc.select(each, add=True) chktr = mc.ls(sl=True) check.transforms(chktr) sel = pmc.ls(sl=True) mc.select(cl=True) # create a txt file with infos for the time. temp_dir = charvalue + 'frames' with open(temp_dir + '.txt', "w") as f: f.write(str(qst) + ';' + str(qend)) f.close() # dump "rig" folders out of the export. # create the folders that will be exported. for each in sel: assets = mc.listRelatives(str(each), c=True) print(assets) for asset in assets: folders = None try: folders = mc.listRelatives(str(asset), c=True) except ValueError: print( asset + ' seems to exist more than once. Full export will be performed.' ) if folders == ['mod', 'rig']: print('asset chelou') else: print('Full export is performed.') print('________________________________') print('________________________________') if os.path.exists(charvalue): go_on = mc.confirmDialog(title='Exporting Alembic !!', message='An ABC already exists for : ' + filevalue + ', do you want to overwrite it ?', button=['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No') if go_on == 'No': sys.exit('Alembic Export Aborted') for each in sel: abc_name = charvalue + each + '.abc' node_to_export = [] node_to_export.append(each) abc_custom_export(framemode=mode, qstart=qst, qend=qend, preroll=False, path=abc_name, preframe=0, nodes=node_to_export) temp_dir = project_dir + '\\utils\\export\\clean_abc' with open(temp_dir + '.txt', "w") as f: f.write(str(charvalue)) f.close() if ('chars' in check_name) or ('props' in check_name): # launch the ABC cleaner print('---------------------------------------------------') print('---------------------------------------------------') print('Launching The Alembic Cleaner... Please wait.') import utils.mayapy as mp reload(mp) mp.launch_mayapy() print('Alembic : ' + filevalue + ' successfully created !')
obj_path = project_dir + '\\utils\\export\\clean_abc' file_path = open(obj_path + '.txt', 'r') abc_path = file_path.read() file_path.close() except ValueError: print('No file to read a text from.') sys.exit('GOODBYE DOGGIE') print('These are the ABC files found :') print(' ') for each in os.listdir(abc_path): file, ext = gx.get_ext(each) if ext == 'abc': print(each) try: abc_path = abc_path.split(';') except IndexError: abc_path = [abc_path] import maya.standalone maya.standalone.initialize() maya.standalone.initialize('Python') import maya.cmds as mc import pymel.core as pmc import utils.save as save
def master(comments='', merge_refs=False, bin_or_ascii='mayaBinary', ask_version=True): print('Master save STARTED') filename = mc.file(q=True, sn=True) charvalue = filename.split('/') # Verifier que l'on est dans le projet if not project_name in charvalue: sys.exit('You are not working in the Project !!') # Sortir l'emplacement du fichier seulement file_path = charvalue[:-2] file_path = '/'.join(file_path) filevalue = charvalue[-2] file_type, extension = ext.get_ext(charvalue[-1]) charvalue.pop(-1) charvalue.pop(-1) charvalue = '/'.join(charvalue) charvalue = charvalue + '/master' new_name = filename if ask_version == True: go_on = mc.confirmDialog( title='Save Version First ?', message='Do you want to save a version for the asset : ' + file_type.capitalize() + ' before saving a Master file ?', button=['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No') print('charvalue ==> ' + charvalue) if go_on == 'Yes': new_name = version() if os.path.exists(charvalue): go_on = mc.confirmDialog( title='Saving Master', message='A MASTER file already exists for : ' + file_type.capitalize() + ', do you want to overwrite it ?', button=['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No') if go_on == 'No': if ask_version == False: mc.file(new_name, open=True, force=True) sys.exit('Master creation aborted') else: os.mkdir(charvalue) date = time.strftime('%c') hour = time.strftime('%x') if not comments == '': comments = ' ____ ' + comments with open(charvalue + '/' + 'infos.txt', "a") as f: f.write('\r\n' + date + ' by ' + pc_name + ' : from ' + filevalue + comments) mc.file(rename=charvalue + '/' + file_type) # query the references in the scene if merge_refs == True: namespaces = mc.namespaceInfo(listOnlyNamespaces=True) namespaces.pop(0) namespaces.pop(-1) for each in namespaces: mc.namespace(removeNamespace=each, mnr=True) sel = mc.ls(references=True) for each in sel: each = mc.referenceQuery(each, filename=True) mc.file(each, ir=True) try: mc.file(save=True, type='mayaBinary') except RuntimeError: mc.file(save=True, type='mayaAscii') create.thumbnail() print(new_name) mc.file(new_name, open=True) mc.warning('Master created !')
def g_asset_export(cache = 2, refs=1): filename = mc.file(q=True, sn=True) charvalue = filename.split('/') # Verifier que l'on est dans le projet if not project_name in charvalue: sys.exit('You are not working in the Project !!') # Sortir l'emplacement du fichier seulement file_path = charvalue[:-1] filevalue = charvalue[-1] print('filevalue => ' + filevalue) filevalue, extension = ext.get_ext(filevalue) if cache == 1: go_on = mc.confirmDialog(title='Creating Guerilla Project', message = 'Export Cache Only selected. Continue ?', button =['Yes','No'], defaultButton='Yes', cancelButton='No', dismissString='No') if go_on == 'No': sys.exit('Guerilla Project creation aborted') file_path.pop(-1) file_path.pop(-1) print(charvalue) file_path = '/'.join(file_path) print('file_path => '+ file_path) print(filevalue) if not cache == 1: if not file_path + '/guerilla/V000': os.mkdir(file_path + '/guerilla/V000') charvalue = file_path + '/' + 'guerilla/' + 'tex' version_path = file_path + '/' + 'guerilla/V000/' + 'tex' print(charvalue) if not cache == 1: if os.path.exists(charvalue + '.gproject'): go_on = mc.confirmDialog(title='Creating Guerilla Project', message = 'A gproject file already exists for : ' + filevalue + '_tex, do you want to overwrite it ?', button =['Yes','No'], defaultButton='Yes', cancelButton='No', dismissString='No') if go_on == 'No': sys.exit('Guerilla Project creation aborted') mc.GuerillaExport(mode=cache, cgr=refs, fte=2, pf=version_path + '.gproject', cf=charvalue + '.ghostproject') print('Guerilla asset project : ' + filevalue + '_tex' + ' successfully created !')
try: file_path = open(temp_dir + '.txt', 'r') seq_path = file_path.read() file_path.close() seq_path = seq_path.split(';') ref_list = [seq_path[2]] last_frame = seq_path[1] seq_path = seq_path[0] print('ref_list = ' + str(ref_list)) seq_name = seq_path.split('/') seq_name = seq_name[-1] seq_name, asset_ext = ext.get_ext(seq_name) write_path = project_dir + '/prod/seq/' + seq_name + '/lookdev/guerilla/' a = dict({'prefixnodes': False, 'containschildren': False}) doc.LastFrame.set(int(last_frame)) rPass = pynode('RenderPass') # add a reference with Modifier() as mod: refNode, topNodes = mod.createref(seq_name + '__ref', seq_path, parent=None,