Пример #1
0
def rollback_tool_go(node=None):
    global rollback_window
    global asset_name
    global src

    if node is None:
        nodes = hou.selectedNodes()
        if len(nodes) == 1:
            node = nodes[0]
        elif len(nodes) > 1:
            message_gui.error('Please select only one node to rollback')
            return
        elif len(nodes) < 1:
            message_gui.error('Please select a node to rollback')
            return

    project = Project()
    src = node.type().definition().libraryFilePath()
    asset_name = os.path.basename(src)
    index = asset_name.find('_hda')
    if index > 0:
        base_name = asset_name[:index]
    else:
        message_gui.error('There was a problem finding the tool')
        return
    body = project.get_body(base_name)
    element = body.get_element(Department.HDA)
    rollback_window = RollbackWindow(element, hou.ui.mainQtWindow())
    rollback_window.finished.connect(rollback_hda)
def publish_hda():
    project = Project()
    environment = Environment()
    
    if publish_window.published:
        user = publish_window.user
        comment = publish_window.comment
        
        if is_asset:
            if asset_name in project.list_assets():
                body = project.get_asset(asset_name)
                
            if os.path.exists(src):
                if body is not None:
                    if Element.DEFAULT_NAME in body.list_elements(Department.ASSEMBLY):
                        #save node definition
                        asset.type().definition().updateFromNode(asset)
                        asset.matchCurrentDefinition()
                        element = body.get_element(Department.ASSEMBLY, Element.DEFAULT_NAME)
                        dst = element.publish(user, src, comment)
                        #Ensure file has correct permissions
                        try:
                            os.chmod(dst, 0660)
                        except:
                            pass
                        hou.hda.uninstallFile(src, change_oplibraries_file=False)
                        saveFile = asset_name + "_assembly_main.hdanc"
                        dst = os.path.join(environment.get_assembly_dir(), saveFile)
                        hou.hda.installFile(dst)
            else:
                hou.ui.displayMessage("File does not exist")
Пример #3
0
def publish_hda():
    project = Project()
    environment = Environment()

    if publish_window.published:
        user = publish_window.user
        comment = publish_window.comment

        if is_asset:
            if asset_name in project.list_assets():
                body = project.get_asset(asset_name)

            if os.path.exists(src):
                if body is not None:
                    if Element.DEFAULT_NAME in body.list_elements(
                            Department.ASSEMBLY):
                        #save node definition
                        asset.type().definition().updateFromNode(asset)
                        asset.matchCurrentDefinition()
                        element = body.get_element(Department.ASSEMBLY,
                                                   Element.DEFAULT_NAME)
                        dst = element.publish(user, src, comment)
                        #Ensure file has correct permissions
                        try:
                            os.chmod(dst, 0660)
                        except:
                            pass
                        hou.hda.uninstallFile(src,
                                              change_oplibraries_file=False)
                        saveFile = asset_name + "_assembly_main.hdanc"
                        dst = os.path.join(environment.get_assembly_dir(),
                                           saveFile)
                        hou.hda.installFile(dst)
            else:
                hou.ui.displayMessage("File does not exist")
def assemble_hda():
    asset_name = checkout_window.current_item

    project = Project()
    username = project.get_current_username()
    asset = project.get_asset(asset_name)
    
    assembly = asset.get_element(Department.ASSEMBLY)
    checkout_file = assembly.checkout(username)

    element = asset.get_element(Department.MODEL)
    cache = element.get_cache_dir()
    cache = cache.replace(project.get_project_dir(), '$JOB')
    # TODO: only load files whose extension matches element.get_cache_ext()
    geo_files = [x for x in os.listdir(element.get_cache_dir()) if not os.path.isdir(x)]

    obj = hou.node('/obj')
    subnet = obj.createNode('subnet')
    for geo_file in geo_files:
        geo = subnet.createNode('geo')
        for child in geo.children():
            child.destroy()
        abc = geo.createNode('alembic')
        geo_file_path = os.path.join(cache, geo_file)
        abc.parm('fileName').set(geo_file_path)
        name = ''.join(geo_file.split('.')[:-1])
        geo.setName(name, unique_name=True)

    subnet.setName(asset_name, unique_name=True)
Пример #5
0
def published_definition(asset_name, department):
    # Set the node type correctly
    category = hou.objNodeTypeCategory() if department in this.byu_character_departments else hou.sopNodeTypeCategory()
    hou.hda.reloadAllFiles()

    # Get the HDA File Path
    hda_name = asset_name + "_" + department
    hda_file = hda_name + "_main.hdanc"
    new_hda_path = os.path.join(Project().get_project_dir(), "production", "hda", hda_file)
    old_hda_path = os.path.join(Project().get_project_dir(), "production", "otls", hda_file)

    hda_path = ""
    # Does it exist?
    if os.path.islink(new_hda_path):
        hda_path = os.readlink(new_hda_path)
    elif os.path.islink(old_hda_path):
        hda_path = os.readlink(old_hda_path)
    else:
        return False

    # If it does, grab the definition
    hou.hda.installFile(hda_path)
    hda_definition = hou.hdaDefinition(category, hda_name, hda_path)

    # If the definition failed for some reason, don't tab it in.
    if hda_definition is not None:
        hda_definition.setPreferred(True)
        return True
    else:
        return False
Пример #6
0
def assemble_hda():
    asset_name = checkout_window.current_item

    project = Project()
    username = project.get_current_username()
    asset = project.get_asset(asset_name)

    assembly = asset.get_element(Department.ASSEMBLY)
    checkout_file = assembly.checkout(username)

    element = asset.get_element(Department.MODEL)
    cache = element.get_cache_dir()
    cache = cache.replace(project.get_project_dir(), '$JOB')
    # TODO: only load files whose extension matches element.get_cache_ext()
    geo_files = [
        x for x in os.listdir(element.get_cache_dir()) if not os.path.isdir(x)
    ]

    obj = hou.node('/obj')
    subnet = obj.createNode('subnet')
    for geo_file in geo_files:
        geo = subnet.createNode('geo')
        for child in geo.children():
            child.destroy()
        abc = geo.createNode('alembic')
        geo_file_path = os.path.join(cache, geo_file)
        abc.parm('fileName').set(geo_file_path)
        name = ''.join(geo_file.split('.')[:-1])
        geo.setName(name, unique_name=True)

    subnet.setName(asset_name, unique_name=True)
Пример #7
0
def rollback_shot_go():
    scene_name = hou.hipFile.name()
    shot = os.path.basename(scene_name)
    index = shot.find('_lighting')
    if index > 0:
        base_name = shot[:index]
        department = Department.LIGHTING
    else:
        index = shot.find('_fx')
        if index > 0:
            base_name = shot[:index]
            department = Department.FX
        else:
            # If there is no shot opened then we allow the user to select one from all of the comps.
            global rollback_selection_window
            rollback_selection_window = SelectionWindow(
                hou.ui.mainQtWindow(),
                dept_list=[Department.LIGHTING, Department.FX])
            rollback_selection_window.finished.connect(post_selection)
            return
    print base_name
    project = Project()
    body = project.get_body(base_name)
    element = body.get_element(department)

    global rollback_window
    rollback_window = RollbackWindow(element, hou.ui.mainQtWindow())
    rollback_window.finished.connect(rollback_shot)
Пример #8
0
def create_shot_menu(hideWhen=None, callback_script=None):
    script = '''
from byuam.project import Project

project = Project()
directory_list = list()

shots = project.list_shots()

for shot in shots:
	directory_list.append(shot)
	directory_list.append(shot)

return directory_list
	'''
    project = Project()
    first_shot = (str(project.list_shots()[0]), )
    print first_shot
    shot = hou.StringParmTemplate(
        'shot',
        'Shot',
        1,
        item_generator_script=script,
        menu_type=hou.menuType.Normal,
        script_callback=callback_script,
        script_callback_language=hou.scriptLanguage.Python,
        default_value=first_shot)
    print shot.defaultValue()
    if hideWhen is not None:
        shot.setConditional(hou.parmCondType.HideWhen, '{ ' + hideWhen + ' }')
    return shot
Пример #9
0
def go():
    global rollback_window
    global src
    global asset_name
    nodes = hou.selectedNodes()
    project = Project()
    if len(nodes) == 1:
        asset = nodes[0]
        src = asset.type().definition().libraryFilePath()
        asset_name = os.path.basename(src)
        index = asset_name.find("_assembly")
        if index > 0:
            base_name = asset_name[:index]
        body = project.get_body(base_name)
        element = body.get_element(Department.ASSEMBLY)
        rollback_window = RollbackWindow(element, hou.ui.mainQtWindow())
        rollback_window.finished.connect(rollback_hda)
    else:
        scene_name = hou.hipFile.name()
        shot = os.path.basename(scene_name)
        index = shot.find("_lighting")
        if index > 0:
            base_name = shot[:index]
        print base_name
        body = project.get_body(base_name)
        element = body.get_element(Department.LIGHTING)
        rollback_window = RollbackWindow(element, hou.ui.mainQtWindow())
        rollback_window.finished.connect(rollback_shot)
def rego():
    '''
    reassembles the currently selected node. That means leaving all of the shop nets in place but throwing out the geo and bringing it in fresh.
    '''

    selection = hou.selectedNodes()

    if len(selection) > 1:
        message_gui.error('Please only select one item')
        return
    if len(selection) <1:
        message_gui.error('Please select an item to be reassembled')
        return

    hda = selection[0]

    name = hda.type().name()
    index = name.rfind('_')
    main = name[index:]
    asset_name = name[:index]

    if main.find('_main') == -1:
        message_gui.error('There was something wrong with the name. Try tabbing in the asset again and trying one more time.')
        return

    project = Project()
    environment = Environment()
    username = project.get_current_username()
    asset = project.get_asset(asset_name)
    assembly = asset.get_element(Department.ASSEMBLY)
    # Checkout assembly
    checkout_file = checkout.checkout_hda(hda, project, environment)
    reassemble(hda, project, environment, assembly, asset, checkout_file)
Пример #11
0
def update_contents_geo(node, asset_name, excluded_departments=[], mode=UpdateModes.SMART):

    # Set up the body/elements and make sure it's a character. Just do some simple error checking.
    body = Project().get_body(asset_name)
    if body is None:
        error_message("Asset doesn't exist.")
        return None
    if not body.is_asset() or body.get_type() == AssetType.SET or "byu_geo" not in node.type().name():
        error_message("Must be a prop or character.")
        return None

    # Get interior nodes
    importnode = node.node("import")
    inside = node.node("inside")

    # Set the asset_name and reload
    if node.parm("asset_name").evalAsString() != asset_name:
        node.parm("asset_name").set(asset_name)
    importnode.parm("reload").pressButton()

    # Tab in each content HDA based on department
    for department in this.byu_geo_departments:
        # If the department is not excluded, tab-in/update the content node like normal
        if department not in excluded_departments:
            update_content_node(node, inside, asset_name, department, mode, inherit_parameters = department == Department.MODIFY)

        # If the department is excluded, we should delete it.
        elif mode == UpdateModes.CLEAN:
            destroy_if_there(inside, department)


    inside.layoutChildren()

    return node
Пример #12
0
 def __init__(self, parent, renderNodes):
     super(ExportDialog, self).__init__()
     self.parent = parent
     self.project = Project()
     self.environment = Environment()
     self.renderNodes = renderNodes
     self.initUI()
Пример #13
0
def json_audit():
    project = Project()
    environment = Environment()

    asset_dir = project.get_assets_dir()

    failed_str = ""
    for i, asset in enumerate(project.list_assets(AssetType.PROP)):

        try:
            asset_obj = project.get_body(asset)
            element_obj = asset_obj.get_element(Department.MODEL,
                                                force_create=True)
            element_path = element_obj.checkout(
                environment.get_current_username())
            checkout.non_gui_open(element_path, asset)
            json_exporter_non_gui.exportProp(asset_obj)
        except Exception, err:
            error_str = ""
            error_str += "\nError exporting JSON for {0}".format(asset)
            error_str += "\n" + traceback.format_exc()
            print error_str

            failed_str += error_str
            continue
Пример #14
0
    def __init__(self, parent=None):
        QtGui.QDialog.__init__(self, parent)
        self.setWindowTitle("Email")
        # palette = parent.palette
        self.setPalette(parent.palette)

        self.project = Project()
        self.username = self.project.get_current_username()
        self.user = self.project.get_user(self.username)
        self.user_fullname = self.user.get_fullname()

        request_str = '<span style=" font-size:12pt; font-weight:600;">Please input your email address</span>'
        info_str = "username: "******"\nfull name: " + self.user_fullname
        self.request_label = QtGui.QLabel(request_str)
        self.info_label = QtGui.QLabel(info_str)

        input_str = "email:"
        self.input_label = QtGui.QLabel(input_str)

        self.input = QtGui.QLineEdit()
        self.input.textChanged.connect(self._check_valid)

        self.accept_button = QtGui.QPushButton("OK")
        self.accept_button.setEnabled(False)
        self.accept_button.clicked.connect(self._store_email)

        self.layout = QtGui.QVBoxLayout(self)
        self.layout.addWidget(self.request_label)
        self.layout.addWidget(self.info_label)
        self.input_layout = QtGui.QHBoxLayout()
        self.input_layout.addWidget(self.input_label)
        self.input_layout.addWidget(self.input)
        self.layout.addLayout(self.input_layout)
        self.layout.addWidget(self.accept_button)
Пример #15
0
def publish_hda(publishWindow, selectedHDA, src):
	project = Project()
	environment = Environment()

	if publishWindow.published:

		user = publishWindow.user
		comment = publishWindow.comment
		hdaName = selectedHDA.type().name()
        department = publishWindow.elementName
        # TODO: UGLY HOTFIX FOR OLD ASSEMBLY & TOOL ASSETS
        asset_name = hdaName.replace("_" + department, "") if department not in [Department.ASSEMBLY, Department.HDA] else hdaName.replace("_main", "")
        body = project.get_body(asset_name)

        if body is None:
            message_gui.error("Asset not found in pipe.")
            return

        if os.path.exists(src):
            try:
                #save node definition this is the same as the Save Node Type menu option. Just to make sure I remember how this works - We are getting the definition of the selected hda and calling the function on it passing in the selected hda. We are not calling the funciton on the selected hda.
                selectedHDA.type().definition().updateFromNode(selectedHDA)
            except hou.OperationFailed, e:
                message_gui.error('There was a problem publishing the HDA to the pipeline.\n', details=str(e))
                return
            try:
                selectedHDA.matchCurrentDefinition()
            except hou.OperationFailed, e:
                message_gui.warning('There was a problem while trying to match the current definition. It\'s not a critical problem but it is a little troubling. Take a look at it and see if you can resolve the problem. Rest assured that the publish did work though', details=str(e))
Пример #16
0
def go():
    try:
        scene_name = mari.projects.current().name()
    except:
        message_gui.error(
            "You need to open the project that you would like to rollback.")
        return

    shot = os.path.basename(scene_name)
    index = shot.find("_texture")
    if index > 0:
        base_name = shot[:index]
        print base_name
    else:
        message_gui.error(
            "We couldn't figure out what asset you are working on.")
        return

    project = Project()
    body = project.get_body(base_name)
    element = body.get_element(Department.TEXTURE)

    global rollback_window
    parent = QtWidgets.QApplication.activeWindow()
    rollback_window = RollbackWindow(element, parent)
    rollback_window.finished.connect(post_rollback)
Пример #17
0
def confirmWritePropReference(body=None):

    filePath = pm.sceneName()
    fileDir = os.path.dirname(filePath)
    project = Project()

    if not body:
        checkout = project.get_checkout(fileDir)
        bodyName = checkout.get_body_name()
        body = project.get_body(bodyName)

    if body.is_asset() and body.get_type() == AssetType.PROP:
        element = body.get_element(Department.MODEL)
        filePath = os.path.join(project.get_assets_dir(),
                                element.get_cache_dir())
        assemblies = pm.ls(assemblies=True)
        pm.select(pm.listCameras(), replace=True)
        cameras = pm.selected()
        pm.select([])
        non_cameras = [
            assembly for assembly in assemblies if assembly not in cameras
        ]
        exportPropJSON(filePath,
                       non_cameras[0],
                       isReference=False,
                       name=body.get_name())
        showSuccessPopup()
Пример #18
0
def getVersion(renderDir=None):
    if renderDir is None:
        project = Project()
        scene = hou.hipFile.name()
        src_dir = os.path.dirname(scene)
        element = project.get_checkout_element(src_dir)
        if element is None:
            return None
        parent = element.get_parent()
        shot = project.get_shot(parent)
        renderElement = shot.get_element(Department.RENDER)
        renderDir = renderElement.get_dir()

    # Get the sub dir and figure out which is the next version
    subDirs = get_subdirs(renderDir)
    versions = list()
    for subDir in subDirs:
        try:
            versions.append(int(subDir))
        except:
            continue
    if len(versions) == 0:
        return 1
    versions.sort()
    return versions[len(versions) - 1] + 1
Пример #19
0
def byu_geo(parent, asset_name, already_tabbed_in_node=None, excluded_departments=[], character=False, mode=UpdateModes.CLEAN):
    # Set up the body/elements and check if it's an asset.
    body = Project().get_body(asset_name)
    if not body.is_asset():
        error_message("Must be an asset.")
        return None

    # Set up the nodes, name geo
    node = already_tabbed_in_node if already_tabbed_in_node else parent.createNode("byu_geo")
    if character:
        node.setName("geo")
    else:
        try:
            node.setName(asset_name.title())
        except:
            node.setName(asset_name.title() + "_1", unique_name=True)

    # Set the asset_name data tag
    data = node.parm("data").evalAsJSONMap()
    data["asset_name"] = asset_name
    node.parm("data").set(data)

    # Set the contents to the nodes that belong to the asset
    update_contents_geo(node, asset_name, excluded_departments, mode)

    return node
def go():
    global checkout_window
    project = Project()
    environment = Environment()
    
    nodes = hou.selectedNodes()
    if len(nodes) == 1:
        #if selected node is digital asset
        if nodes[0].type().definition() is not None:
            asset = nodes[0]
            asset_name = nodes[0].type().name() #get name of asset
            index = asset_name.find("_main")
            asset_name = asset_name[:index]
            src = nodes[0].type().definition().libraryFilePath()
            current_user = environment.get_current_username()
            
            if asset_name in project.list_assets():
                body = project.get_asset(asset_name)
                
            if os.path.exists(src):
                if body is not None: 
                    if Element.DEFAULT_NAME in body.list_elements(Department.ASSEMBLY):
                        element = body.get_element(Department.ASSEMBLY, Element.DEFAULT_NAME)
                        element_path = element.checkout(current_user)
                        hou.hda.uninstallFile(src, change_oplibraries_file=False)
                        hou.hda.installFile(element_path)
                        asset.allowEditingOfContents()
                        hou.ui.displayMessage("Checkout Successful!", title='Success!')
            
    elif len(nodes) > 1:
        hou.ui.displayMessage("Only one node can be selected for checkout")
    else:
        checkout_window = CheckoutWindow(hou.ui.mainQtWindow(), [Department.LIGHTING, Department.FX])    
        checkout_window.finished.connect(checkout_shot)
def create_set_menu(hideWhen=None, callback_script=None, hidden=False, value=None):
    item_gen_script='''
from byuam.project import Project

project = Project()
set_list = list()

sets = project.list_sets()

for set in sets:
    set_list.append(set)
    set_list.append(set.replace('_', ' ').title())

return set_list
    '''
    project = Project()
    if(value == None):
        if len(project.list_sets()) < 1:
            message_gui.error('There are currently no sets in created in the film. Because of how this node works you are going to have to create at least one set before assembling anything.')
            raise('No sets in the project')
        default_set = (str(project.list_sets()[0]),)
    else:
        default_set = (value,)
    #print default_set
    set_menu = hou.StringParmTemplate('set', 'Set', 1, item_generator_script=item_gen_script, is_hidden=hidden, menu_type=hou.menuType.Normal, script_callback=callback_script, script_callback_language=hou.scriptLanguage.Python, default_value=default_set)
    #print set_menu.defaultValue()
    if hideWhen is not None:
        set_menu.setConditional( hou.parmCondType.HideWhen, '{ ' + hideWhen + ' }')
    return set_menu
Пример #22
0
def post_publish():
    global maya_publish_dialog
    element = maya_publish_dialog.result
    if element.get_department() == Department.ANIM:
        confirmWriteShotReferences(Project().get_body(element.get_parent()))
    else:
        confirmWriteSetReferences(Project().get_body(element.get_parent()))
Пример #23
0
def super_print(message):
    with open(os.path.join(Project().get_users_dir(), Project().get_current_username(), "houdini_log.txt"), "a+") as f:
        print(message)
        sys.stdout.flush()
        f.write("\n" + str(datetime.datetime.now()) + "\n")
        f.write(message)
        f.flush()
Пример #24
0
def go():
	print "Start copy"
	project = Project()
	proDir = project.get_project_dir()
	path = os.path.join(proDir, 'byu-pipeline-tools', 'nuke-tools', 'templates', 'grendel_general_template.nk')
	print path
	nuke.nodePaste(path)
	print "Finsih Copy"
Пример #25
0
def getShotName():
    project = Project()
    scene = hou.hipFile.name()
    src_dir = os.path.dirname(scene)
    element = project.get_checkout_element(src_dir)
    if element is None:
        return None
    return element.get_parent()
Пример #26
0
def post_assemble():
    mari.projects.close()
    asset_name = mari_assemble_dialog.result
    print asset_name

    if asset_name is None:
        return

    # Set up the project and environment
    project = Project()
    environment = Environment()
    # get the username and asset
    username = project.get_current_username()
    asset = project.get_asset(asset_name)

    # get the texture element and check it out
    texture = asset.get_element(Department.TEXTURE)
    checkout_file = texture.checkout(username)

    # Get the path to the directory with all of the alembics
    model = asset.get_element(Department.MODEL)
    cache = model.get_cache_dir()

    geo_files = [
        x for x in os.listdir(model.get_cache_dir()) if not os.path.isdir(x)
    ]
    # Remove anything that is not an alemibic file
    for file_path in list(geo_files):
        if (not str(file_path).lower().endswith('.abc')):
            geo_files.remove(file_path)

    if len(geo_files) > 1:
        result = message_gui.light_error(
            'There are multiple alembic files in ' + str(file_path) +
            ' and there should only be one.\nWould you like to continue anyways?\nIt might not work.'
        )
        if not result:
            return
    elif len(geo_files) > 1:
        message_gui.error(
            'There is not an alembic cache for this asset. Make sure that the model has been published in Maya and that the static alembic has been exported.'
        )
        return

    geo_file_path = os.path.join(cache, geo_files[0])
    mari.projects.create(
        texture.get_long_name(), geo_file_path, [], [], dict(), [
            {
                '/': mari.geo.GEOMETRY_IMPORT_DONT_MERGE_CHILDREN
            },
        ])

    # At this point there should be no files left to add but if there are then the user was warned about it and we can go ahead and try to load those in.
    # This was from when we exported a bunch of alembics from Maya instead of just one. And since it shouldn't get called unless something goes wrong I figure it might be interesting to see what would happen if something goes wrong so we might as well leave it.
    for i in range(1, len(geo_files)):
        geo_file_path = os.path.join(cache, geo_files[i])
        mari.geo.load(geo_file_path)
        print 'Loaded ' + geo_file_path
Пример #27
0
def check_user_email(parent=None):
    """
    Check if the current user has an email address. If not, open an email request dialog.
    parent -- the widget to parent the dialog to
    """
    project = Project()
    user = project.get_user()
    if user.get_email() == "":
        dialog = RequestEmailDialog(parent)
        dialog.show()
Пример #28
0
def get_texture():
    project_name = mari.projects.current().name()
    index = project_name.find('_texture')
    if index > 0:
        asset_name = project_name[:index]
        project = Project()
        asset = project.get_asset(asset_name)
        return asset.get_element(Department.TEXTURE)
    else:
        return None
def check_user_email(parent=None):
    """
    Check if the current user has an email address. If not, open an email request dialog.
    parent -- the widget to parent the dialog to
    """
    project = Project()
    user = project.get_user()
    if user.get_email()=="":
        dialog = RequestEmailDialog(parent)
        dialog.show()
def export(element, selection=None, startFrame=None, endFrame=None):
    proj = Project()
    bodyName = element.get_parent()
    body = proj.get_body(bodyName)
    abcFilePath = element.get_cache_dir()
    #TODO we don't want to put them into the element cache right away. We want to put them in a seperate place and then copy them over later.

    if startFrame is None:
        startFrame = pm.playbackOptions(q=True, animationStartTime=True)
    if endFrame is None:
        endFrame = pm.playbackOptions(q=True, animationEndTime=True)

    if body.is_shot():
        startFrame -= 5
        endFrame += 5
        files = exportReferences(abcFilePath,
                                 tag='BYU_Alembic_Export_Flag',
                                 selectionMode=True,
                                 startFrame=startFrame,
                                 endFrame=endFrame)
        result = message_gui.yes_or_no(
            'Are there any crowds that need to be exported?')
        if result:
            exportCrowd(abcFilePath,
                        'BYU_Crowd_Agent_Flag',
                        tag='BYU_Alembic_Export_Flag',
                        startFrame=startFrame,
                        endFrame=endFrame)
    elif body.is_asset():
        if body.get_type() == AssetType.SET:
            files = exportReferences(abcFilePath)
        else:
            files = exportAll(abcFilePath, element=element)
    elif body.is_crowd_cycle():
        files = exportAll(abcFilePath,
                          tag='BYU_Alembic_Export_Flag',
                          startFrame=startFrame,
                          endFrame=endFrame,
                          element=element)

    if not files:
        #Maybe this is a bad distinction but None is if it was canceled or something and empty is if it went but there weren't any alembics
        if files is None:
            return
        message_gui.error('No alembics were exported')
        return

    for abcFile in files:
        os.system('chmod 774 ' + abcFile)

    #TODO install the geometry
    print 'These are the files that we are returning', files
    return files
Пример #31
0
def update_contents_character(node, asset_name, excluded_departments=[], mode=UpdateModes.SMART, shot=None):

    ##super_print("{0}() line {1}:\n\tcharacter: {2}\n\tmode: {3}".format(method_name(), lineno(), asset_name, mode))
    # Set up the body/elements and make sure it's a character. Just do some simple error checking.
    body = Project().get_body(asset_name)
    if not body.is_asset() or body.get_type() != AssetType.CHARACTER or "byu_character" not in node.type().name():
        error_message("Must be a character.")
        return None

    # Reset the data parm
    data = node.parm("data").evalAsJSONMap()
    data["asset_name"] = asset_name
    node.parm("data").set(data)

    inside = node.node("inside")

    # Make sure the geo is set correctly
    geo = inside.node("geo")
    if geo is not None:
        if mode == UpdateModes.SMART:
            update_contents_geo(geo, asset_name, excluded_departments, mode)

        elif mode == UpdateModes.CLEAN:
            geo.destroy()
            geo = byu_geo(inside, asset_name, excluded_departments=excluded_departments, character=True)
    else:
        geo = byu_geo(inside, asset_name, excluded_departments=excluded_departments, character=True)

    # Tab in each content HDA based on department
    for department in this.byu_character_departments:
        # If the department is not excluded, tab-in/update the content node like normal
        if department not in excluded_departments:

            update_content_node(node, inside, asset_name, department, mode)

        # If the department is excluded, we should delete it.
        elif mode == UpdateModes.CLEAN:

            destroy_if_there(inside, department)


    inside.layoutChildren()

    geo.parm("version_number").setExpression("ch(\"../../version_number\")", language=hou.exprLanguage.Hscript)

    # If this character is being animated, set parms accordingly
    if shot is not None:
        geo.parm("space").set("anim")
        geo.parm("asset_department").set("rig")
        geo.parm("shot").set(shot)

    return node
Пример #32
0
def saveHipRenderCopy():
    import shutil
    src = hou.hipFile.path()
    hou.hipFile.save()
    proj = Project()
    projDir = proj.get_project_dir()
    renderCache = os.path.join(projDir, 'production', 'renderCache')
    if not os.path.exists(renderCache):
        os.makedirs(renderCache)
    dstFile = 'preRender' + hou.hipFile.basename()
    dst = os.path.join(renderCache, dstFile)
    shutil.copyfile(src, dst)
    return dst
Пример #33
0
def mass_xml():
    project = Project()

    errors = []
    for asset in project.list_assets():
        try:
            byu_xml.writeXML(asset)

        except Exception as e:
            print asset
            errors.append(asset)

    if len(errors) > 0:
        print 'failed generating xml for: ' + str(errors)
Пример #34
0
def go():

	result = message_gui.binary_option("We are going to do crowds cycles a little differently now. This way is going to be more direct, less error prone and there is going to be a lot less stuff for maya to load so it should make the process a little faster. We are going to do it just like we would make any other asset with a couple of differences. I think it's going to work out a lot better.", "View Instuctions", "Done")

	if result:
		subprocess.call(['xdg-open', 'https://byu-animation.github.io/crowds.html'])

	return

	fileName = pm.sceneName()
	listOfChanges = pm.dgmodified()

	#Check to see if there are unsaved changes
	if listOfChanges is not None:
		result = message_gui.yes_or_no('In order to continue the file will need to be saved and closed. Are you ready to proceed?')
		if not result:
			return None

	name = message_gui.input('What is the name of this cycle?')
	if name is None:
		return None

	invalidInput = True
	while(invalidInput):
		firstFrame = message_gui.input('What is the first frame of the cycle?')
		try:
			firstFrame = int(firstFrame)
		except ValueError:
			message_gui.error('Please enter a number')
			continue
		invalidInput = False

	invalidInput = True
	while(invalidInput):
		lastFrame = message_gui.input('What is the last frame of the cycle?')
		try:
			lastFrame = int(lastFrame)
		except ValueError:
			message_gui.error('Please enter a number')
			continue
		invalidInput = False

	name = name.replace(' ', '_')
	project = Project()
	try:
		cycleAsset = project.create_crowd_cycle(name)
	except EnvironmentError, e:
		message_gui.error('There is already an crowd cycle with that name.', details=e)
		return None
    def __init__(self, parent=None):
        QtGui.QDialog.__init__(self, parent)
        self.setWindowTitle("Email")
        # palette = parent.palette
        self.setPalette(parent.palette)

        self.project = Project()
        self.username = self.project.get_current_username()
        self.user = self.project.get_user(self.username)
        self.user_fullname = self.user.get_fullname()
        
        request_str = '<span style=" font-size:12pt; font-weight:600;">Please input your email address</span>'
        info_str = "username: "******"\nfull name: "+self.user_fullname
        self.request_label = QtGui.QLabel(request_str)
        self.info_label = QtGui.QLabel(info_str)

        input_str = "email:"
        self.input_label = QtGui.QLabel(input_str)

        self.input = QtGui.QLineEdit()
        self.input.textChanged.connect(self._check_valid)

        self.accept_button = QtGui.QPushButton("OK")
        self.accept_button.setEnabled(False)
        self.accept_button.clicked.connect(self._store_email)

        self.layout = QtGui.QVBoxLayout(self)
        self.layout.addWidget(self.request_label)
        self.layout.addWidget(self.info_label)
        self.input_layout = QtGui.QHBoxLayout()
        self.input_layout.addWidget(self.input_label)
        self.input_layout.addWidget(self.input)
        self.layout.addLayout(self.input_layout)
        self.layout.addWidget(self.accept_button)
def go():

    project = Project()
    filepath = cmds.file(q=True, sceneName=True)

    checkout = project.get_checkout(os.path.dirname(filepath))
    if checkout is not None:
        body_name = checkout.get_body_name()
        body = project.get_body(body_name)
        if body.is_shot():
            frame_range = body.get_frame_range()
            if frame_range > 0:
                print "set frame range to " + str(frame_range)
                cmds.playbackOptions(animationStartTime=1.0, animationEndTime=frame_range, minTime=1.0, maxTime=frame_range, framesPerSecond=24)
            else:
                print "shot has invalid frame range"
        else:
            print "not a shot"  
    else:
        print "Unknown Shot, can't set frame range"