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')
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): # os.mkdir(project_path) # os.chmod(project_path, 777) mkfolder.cr_folder(project_path, 777) else: print 'folder already exists !' sys.exit( 'folder already existing => please choose another name or location, or delete the folder if you created one by mistake.' ) subpath = project_path + '/preprod' # sous dossiers os.mkdir(subpath) os.mkdir(subpath + '/refs') os.mkdir(subpath + '/concept') os.mkdir(subpath + '/scenario')
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)
def asset(asset_name, asset_type): ''' Creates an asset in the project. creates_asset() takes two arguments : asset_name = string type (ex : 'Gilles') asset_type = string type but one of these (unless you added more) : 'Chars','Props','Sets' Write the function as : create_asset(asset_name, asset_type) ( ex : create_asset('Gilles', 'Chars') will create an asset named Gilles in the 'Chars' folder of your project. ) ''' # ASSET CREATOR # asset_name = 'gilles' # asset_type = 'chars' # asset_state = 'modeling' asset_name = asset_name.lower() if asset_type == '': sys.exit('Pas de chemin existant !') if asset_name == '': sys.exit('Give your asset a name !') project_path = project_path_base + '/' + project_name asset_path = project_path_base + '/' + project_name + '/prod/assets/' + asset_type asset_fullpath = asset_path + '/' + asset_name asset_path = asset_path.replace('/', '\\') asset_fullpath = asset_fullpath.replace('/', '\\') retval = os.getcwd() os.chdir(asset_path) retval = os.getcwd() print "Working directory changed to : %s" % retval # Fenetre de dialogue prevenant si on a bien sauve la scene go_on = mc.confirmDialog( title='Creating new asset : ' + asset_name, message="Your current file won't be saved, are you sure ?", button=['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No') if go_on == 'Yes': if not os.path.exists(asset_fullpath): mkfolder.cr_folder(asset_fullpath, 777) mkfolder.cr_folder(asset_fullpath + '\\mod', 777) mkfolder.cr_folder(asset_fullpath + '\\mod\\V000', 777) mkfolder.cr_folder(asset_fullpath + '\\rig', 777) mkfolder.cr_folder(asset_fullpath + '\\rig\\V000', 777) mkfolder.cr_folder(asset_fullpath + '\\zbrush', 777) mkfolder.cr_folder(asset_fullpath + '\\export', 777) mkfolder.cr_folder(asset_fullpath + '\\lookdev', 777) mkfolder.cr_folder(asset_fullpath + '\\lookdev\\guerilla', 777) mkfolder.cr_folder(asset_fullpath + '\\lookdev\\mari', 777) mkfolder.cr_folder(asset_fullpath + '\\lookdev\\textures', 777) else: sys.exit('asset name already existing !') mc.file(new=True, f=True) mc.textCurves(f='Arial|wt:75|sz:100|sl:n|st:100', t=asset_name) mc.file(rename=asset_fullpath + '\\rig\\V000\\' + 'rig.ma') mc.file(save=True, type='mayaAscii') mc.file(new=True, f=True) mc.textCurves(f='Arial|wt:75|sz:100|sl:n|st:100', t=asset_name) mc.file(rename=asset_fullpath + '\\mod\\V000\\' + 'mod.ma') mc.file(save=True, type='mayaAscii') else: sys.exit('Asset Creation aborted') om.MGlobal.displayInfo("New Asset " + asset_name + " successfully created !")
def asset(asset_name, asset_type): ''' Creates an asset in the project. creates_asset() takes two arguments : asset_name = string type (ex : 'Gilles') asset_type = string type but one of these (unless you added more) : 'Chars','Props','Sets' Write the function as : create_asset(asset_name, asset_type) ( ex : create_asset('Gilles', 'Chars') will create an asset named Gilles in the 'Chars' folder of your project. ) ''' # ASSET CREATOR # asset_name = 'gilles' # asset_type = 'chars' # asset_state = 'modeling' asset_name = asset_name.lower() if asset_type == '': sys.exit('Pas de chemin existant !') if asset_name == '': sys.exit('Give your asset a name !') project_path = project_path_base + '\\' + project_name asset_path = project_path_base + '\\' + project_name + '\\prod\\assets\\' + asset_type asset_fullpath = asset_path + '\\' + asset_name asset_path = asset_path.replace('/', '\\') asset_fullpath = asset_fullpath.replace('/', '\\') retval = os.getcwd() os.chdir(asset_path) retval = os.getcwd() print "Working directory changed to : %s" % retval print(asset_fullpath) # Fenetre de dialogue prevenant si on a bien sauve la scene go_on = mx.queryBox("Your current file won't be saved, are you sure ?", title='Creating new asset : ' + asset_name) print(go_on) if go_on == True: if not os.path.exists(asset_fullpath): mkfolder.cr_folder(asset_fullpath, 777) mkfolder.cr_folder(asset_fullpath + '\\mod', 777) mkfolder.cr_folder(asset_fullpath + '\\mod\\V000', 777) else: print('asset name already existing !') sys.exit('asset name already existing !') charvalue = asset_fullpath + '\\mod\\V000\\' + 'mod.max' mc.FileManager.Reset() # mc.textCurves(f= 'Arial|wt:75|sz:100|sl:n|st:100', t= asset_name) mx.text(text=asset_name) mc.FileManager.Save(charvalue) else: print('Asset Creation aborted') sys.exit('Asset Creation aborted')