def __init__(self, element, parent): super(RollbackWindow, self).__init__() self.element = element self.parent = parent self.environment = Environment() self.project = Project() self.publishes = [] self.result = None self.initUI() self.list_publishes()
def __init__(self, src, parent, dept_list=Department.ALL): super(PublishWindow, self).__init__() self.environment = Environment() self.project = Project() self.eList = ElementList(self) self.parent = parent self.src = src self.result = None self.elementType = None self.initUI(dept_list) self.published = False
def __init__(self, element, parent): super(RollbackWindow, self).__init__() if element is None: message_gui.error("Please checkout a shot to rollback.\n") return self.element = element self.parent = parent self.environment = Environment() self.project = Project() self.publishes = [] self.result = None self.initUI() self.list_publishes()
def go(body=None, type=AssetType.SET): if not body: parent = publish.maya_main_window() filePath = pm.sceneName() fileDir = os.path.dirname(filePath) project = Project() checkout = project.get_checkout(fileDir) if not checkout: filePath = Environment().get_user_workspace() filePath = os.path.join(filePath, 'untitled.mb') filePath = pipeline_io.version_file(filePath) global maya_publish_dialog selection_list = [] if type == "shot": selection_list = Project().list_shots() elif type == AssetType.PROP: selection_list = [] for asset in Project().list_assets(): body = project.get_body(asset) if body.get_type() != AssetType.PROP: continue selection_list.append(asset) elif type == AssetType.SET: selection_list = Project().list_sets() else: print("Didn't export JSON, because it probably is a character.") return maya_publish_dialog = SelectFromList(parent=maya_main_window()) maya_publish_dialog.setWindowTitle("Select shot" if type == "shot" else "Select prop" if type == AssetType.PROP else "Select set") maya_publish_dialog.setList(selection_list) maya_publish_dialog.filePath = filePath maya_publish_dialog.selected.connect(publish_submitted) maya_publish_dialog.show() else: if type == "shot": confirmWriteShotReferences(body) elif type == AssetType.PROP: confirmWritePropReference(body) elif type == AssetType.SET: confirmWriteSetReferences(body)
def __init__(self, parent, dept_list=Department.ALL): super(CheckoutWindow, self).__init__() self.parent = parent self.project = Project() self.environment = Environment() self.initUI(dept_list)
#### #### Welcome to the shelf script! #### #### If you'd like to add a shelf button, you can add it to #### shelf.json. Follow the example of the other buttons in there. #### Remember, the icon must be a 33X33 .xpm, and the python_file key #### must be the name of the file where your python script is #### stored. (Careful, it's not an absolute path!) #### from pymel.core import * import os import sys import json from byuam.environment import Environment env = Environment() #### CONSTANTS, Edit these for customization. PROJ = env.get_project_name() SHELF_DIR = os.environ.get('MAYA_SHELF_DIR') ICON_DIR = os.path.join(SHELF_DIR, "icons") SCRIPT_DIR = os.path.join(SHELF_DIR, "scripts") #### #### Shelf building code. You shouldn't have to edit anything #### below these lines. If you want to add a new shelf item, #### follow the instructions in shelf.json. sys.path.append(SCRIPT_DIR) def BYU_load_shelf():
selection = mc.ls(selection=True)[0] rigPrefix = re.search(r'\w*main_\w*:?Viking', selection, re.I).group() rigPrefix = "viking_with_facial_rig_main" #until I can figure out that regex lol vikingBodyGeo = rigPrefix + '_body_GEO_01' vikingRigName = rigPrefix + '_primary_global_cc_01' cache_name = rigPrefix # look in shots cfx/main/cache ######################### ## ESTABLISH CFX SCENE ## ######################### project = Project() environment = Environment() # Create a global position locator for viking's starting location mc.currentTime(STARTPRE) globalPos = mc.spaceLocator(p=[0, 0, 0]) globPos = mc.rename(globalPos, "vikingGlobalPos") mc.select(vikingRigName) mc.select(globPos, add=True) mc.pointConstraint( offset=[0, 0, 0], weight=1) #constrains the globPos position to where viking's rig_main is mc.orientConstraint( offset=[0, 0, 0], weight=1 ) #orients the globPos to match viking's rig_main (I think it just does the rotation) # Get transformation variables from globPos locator
#### #### Welcome to the shelf script! #### #### If you'd like to add a shelf button, you can add it to #### shelf.json. Follow the example of the other buttons in there. #### Remember, the icon must be a 33X33 .xpm, and the pythonFile key #### must be the name of the file where your python script is #### stored. (Careful, it's not an absolute path!) #### import pymel.core as pm import os import sys import json from byuam.environment import Environment byuEnv = Environment() #### CONSTANTS, Edit these for customization. PROJ = byuEnv.get_project_name() SHELF_DIR = os.environ.get('MAYA_SHELF_DIR') ICON_DIR = os.path.join(SHELF_DIR, "icons") ICON_DIR = os.path.join(os.environ.get('BYU_TOOLS_DIR'), "assets", "images", "icons", "tool-icons") SCRIPT_DIR = os.path.join(SHELF_DIR, "scripts") #### #### Shelf building code. You shouldn't have to edit anything #### below these lines. If you want to add a new shelf item, #### follow the instructions in shelf.json. sys.path.append(SCRIPT_DIR)
def __init__(self, parent, dept_list=Department.ALL, showWindow=True): super(SelectionWindow, self).__init__() self.parent = parent self.project = Project() self.environment = Environment() self.initUI(dept_list, showWindow)
def go(): project = Project() environment = Environment() # Create a global position locator which will grab Jampa's position despite his scaled translations mc.currentTime(0) globalPos = mc.spaceLocator(p=[0,0,0]) globPos = mc.rename(globalPos, "jampaGlobalPos") mc.select("jampa_rig_main_global_cc_01") mc.select(globPos, add=True) mc.pointConstraint(offset=[0,0,0], weight=1) mc.orientConstraint(offset=[0,0,0], weight=1) # Get transformation variables from globPos locator tx = mc.getAttr(globPos+".translateX") ty = mc.getAttr(globPos+".translateY") tz = mc.getAttr(globPos+".translateZ") rx = mc.getAttr(globPos+".rotateX") ry = mc.getAttr(globPos+".rotateY") rz = mc.getAttr(globPos+".rotateZ") # get alembic filepath for scene's animation (requires prior export) src = mc.file(q=True, sceneName=True) src_dir = os.path.dirname(src) checkout_element = project.get_checkout_element(src_dir) checkout_body_name = checkout_element.get_parent() body = project.get_body(checkout_body_name) element = body.get_element(Department.ANIM) cache_file = os.path.join(element.get_dir(), "cache", "jampa_rig_main.abc") # checkout cfx scene for corresponding shot number current_user = environment.get_current_username() element = body.get_element(Department.CFX) cfx_filepath = element.checkout(current_user) #open cfx file if cfx_filepath is not None: if not mc.file(q=True, sceneName=True) == '': mc.file(save=True, force=True) #save file if not os.path.exists(cfx_filepath): mc.file(new=True, force=True) mc.file(rename=cfx_filepath) mc.file(save=True, force=True) else: mc.file(cfx_filepath, open=True, force=True) # import alembic command = "AbcImport -mode import \"" + cache_file + "\"" maya.mel.eval(command) # delete all geo except jampa skin and rename geometry = mc.ls(geometry=True) transforms = mc.listRelatives(geometry, p=True, path=True) mc.select(transforms, r=True) for geo in mc.ls(sl=True): if(geo != "jampa_rig_main_jampa_geo_body"): mc.delete(geo) collide = "JAMPA_COLLIDE" mc.rename("jampa_rig_main_jampa_geo_body", collide) # reference robe body = project.get_body("jampa_robe") element = body.get_element(Department.MODEL) robe_file = element.get_app_filepath() mc.file(robe_file, reference=True) # set robe transforms to variables above mc.setAttr("jampa_robe_model_main_jampa_robe_sim.translateX", tx) mc.setAttr("jampa_robe_model_main_jampa_robe_sim.translateY", ty) mc.setAttr("jampa_robe_model_main_jampa_robe_sim.translateZ", tz) mc.setAttr("jampa_robe_model_main_jampa_robe_sim.rotateX", rx) mc.setAttr("jampa_robe_model_main_jampa_robe_sim.rotateY", ry) mc.setAttr("jampa_robe_model_main_jampa_robe_sim.rotateZ", rz) # make jampa skin a passive collider mc.select(collide) command = "makeCollideNCloth" maya.mel.eval(command) rigid_shape = "nRigid_jampa" mc.rename("nRigid1", rigid_shape) mc.setAttr(rigid_shape+".stickiness", 0.2) mc.setAttr(rigid_shape+".friction", 0.5) # make cloth objects and display layers of each robe piece jampa_torso = "jampa_robe_model_main_robe_torso_01" jampa_sash = "jampa_robe_model_main_robe_sash_01" jampa_skirt = "jampa_robe_model_main_robe_skirt_01" cloth_pieces = {jampa_torso, jampa_sash, jampa_skirt} command = "createNCloth 0" for cp in cloth_pieces: mc.select(cp) maya.mel.eval(command) mc.rename("nCloth1", "nCloth_"+cp) mc.select(cp) layername = "cloth_"+cp[:-3].replace("robe_model_main_robe_", "") mc.createDisplayLayer(name=layername.upper(), number=1, noRecurse=True) # set appropriate values in nucleus node nucleus = "nucleus_jampa" mc.rename("nucleus1", nucleus) mc.setAttr(nucleus+".subSteps", 30) mc.setAttr(nucleus+".startFrame", -30) mc.setAttr(nucleus+".spaceScale", 0.23) mc.currentTime(-50)
def generateScene(): project = Project() environment = Environment() # Create a global position locator for Ten's Starting Location mc.currentTime(STARTANIM) globalPos = mc.spaceLocator(p=[0, 0, 0]) globPos = mc.rename(globalPos, "tenGlobalPos") mc.select("ten_rig_main_m_global_CTL") mc.select(globPos, add=True) mc.pointConstraint(offset=[0, 0, 0], weight=1) mc.orientConstraint(offset=[0, 0, 0], weight=1) # Get transformation variables from globPos locator tx = mc.getAttr(globPos + ".translateX") ty = mc.getAttr(globPos + ".translateY") tz = mc.getAttr(globPos + ".translateZ") rx = mc.getAttr(globPos + ".rotateX") ry = mc.getAttr(globPos + ".rotateY") rz = mc.getAttr(globPos + ".rotateZ") # get alembic filepath for scene's animation (requires prior export) src = mc.file(q=True, sceneName=True) src_dir = os.path.dirname(src) checkout_element = project.get_checkout_element(src_dir) checkout_body_name = checkout_element.get_parent() body = project.get_body(checkout_body_name) element = body.get_element(Department.ANIM) cache_file = os.path.join(element.get_dir(), "cache", "ten_rig_main.abc") # checkout cfx scene for corresponding shot number current_user = environment.get_current_username() element = body.get_element(Department.CFX) cfx_filepath = element.checkout(current_user) #open cfx file if cfx_filepath is not None: if not mc.file(q=True, sceneName=True) == '': mc.file(save=True, force=True) #save file if not os.path.exists(cfx_filepath): mc.file(new=True, force=True) mc.file(rename=cfx_filepath) mc.file(save=True, force=True) else: mc.file(cfx_filepath, open=True, force=True) # import alembic command = "AbcImport -mode import \"" + cache_file + "\"" maya.mel.eval(command) # delete all geo except ten's skin and rename geometry = mc.ls(geometry=True) transforms = mc.listRelatives(geometry, p=True, path=True) mc.select(transforms, r=True) for geo in mc.ls(sl=True): if (geo != "ten_rig_main_Ten_Skin_RENDER"): mc.delete(geo) collide = "TEN_ANIM" mc.rename("ten_rig_main_Ten_Skin_RENDER", collide) # Reference Ten's Sim Robe body = project.get_body("ten_robe_sim") element = body.get_element(Department.MODEL) robe_file = element.get_app_filepath() mc.file(robe_file, reference=True) # Reference Ten's Hero Robe body = project.get_body("ten_robe") element = body.get_element(Department.MODEL) robe_hero_file = element.get_app_filepath() mc.file(robe_hero_file, reference=True) # Set Sim Robe transforms to variables above mc.setAttr("ten_robe_sim_model_main_ten_cloth.translateX", tx) mc.setAttr("ten_robe_sim_model_main_ten_cloth.translateY", ty) mc.setAttr("ten_robe_sim_model_main_ten_cloth.translateZ", tz) mc.setAttr("ten_robe_sim_model_main_ten_cloth.rotateX", rx) mc.setAttr("ten_robe_sim_model_main_ten_cloth.rotateY", ry) mc.setAttr("ten_robe_sim_model_main_ten_cloth.rotateZ", rz) # Set Hero Robe transforms to variables above mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.translateX", tx) mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.translateY", ty) mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.translateZ", tz) mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.rotateX", rx) mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.rotateY", ry) mc.setAttr("ten_robe_model_main_TEN_ROBE_HERO.rotateZ", rz)
def test_element(self): count = 0 for body in self.bodies: for dept in Department.ALL: try: element = body.get_element(dept) except EnvironmentError: continue count += 1 self.assertEquals(element.get_parent(), body.get_name()) self.assertEquals(element.get_department(), dept) self.assertEquals(element.get_status(), Status.WAIT) element.update_status(Status.DONE) element.update_assigned_user(self.user) self.assertEquals(element.get_status(), Status.DONE) self.assertEquals(element.get_assigned_user(), self.user) element = body.get_element( dept ) # re-read data from file to ensure nothing gets lost in i/o self.assertEquals(element.get_status(), Status.DONE) self.assertEquals(element.get_assigned_user(), self.user) # publish empty file empty_file = os.path.join(Environment().get_user_workspace(), "empty.txt") open(empty_file, 'a').close() element.publish(self.user, empty_file, "first publish") # test checkout checkout_path = element.checkout(self.user) self.assertTrue(os.path.exists(checkout_path)) checkout_path2 = element.checkout(self.user) self.assertTrue(os.path.exists(checkout_path2)) self.assertTrue(self.user in element.list_checkout_users()) self.assertNotEqual(checkout_path, checkout_path2) checkout_dir = element.get_checkout_dir(self.user) checkout = self.project.get_checkout(checkout_dir) self.assertEquals(element.get_parent(), checkout.get_body_name()) self.assertEquals(element.get_department(), checkout.get_department_name()) self.assertEquals(element.get_name(), checkout.get_element_name()) self.assertEquals(self.user, checkout.get_user_name()) self.assertEquals(len(checkout.list_files()), 2) self.assertTrue(checkout_path in checkout.list_files()) self.assertTrue(checkout_path2 in checkout.list_files()) self.assertEquals(len(checkout.list_times()), 2) # test publish comment = "automated testing" element.publish(self.user, checkout_path, comment) self.assertEquals(len(element.list_publishes()), 2) publish = element.get_last_publish() self.assertEquals(self.user, publish[0]) self.assertEquals(comment, publish[2]) self.assertTrue(os.path.exists(element.get_version_dir(0))) element.update_cache(checkout_path) self.assertTrue(os.path.exists(element.get_cache_dir())) self.assertEquals(element.list_cache_files()[0], os.path.basename(checkout_path)) self.assertEquals(count, self.element_count)