コード例 #1
0
    def update_assets(self):
        lists = ShotgunReader().getAssetLists()
        asset_list = lists[0]
        assets = lists[1]

        #update .asset_list
        list_file = open(
            os.path.join(self.project.get_assets_dir(), ".asset_list.txt"),
            "w")
        list_file.truncate(0)
        for name in asset_list:
            list_file.write(name + "\n")
        list_file.close()

        #update .short_asset_list
        list_file = open(
            os.path.join(self.project.get_assets_dir(), ".short_asset_list"),
            "w")
        list_file.truncate(0)

        for asset in assets:
            name = asset["name"]
            variants = asset["children"][:]
            print("name: " + name)
            print("variants: ", variants)

            self.build_asset(name, variants)

            list_file.write(name + "\n")

        list_file.close()

        qd.message("Assets updated successfully.")
コード例 #2
0
    def results(self, value):
        print("Selected asset: " + value[0])
        filename = value[0]

        self.body = Project().get_body(filename)
        self.element = self.body.get_element(Asset.MATERIALS)
        if self.element.get_last_version() >= 0:

            path = self.element.get_last_publish()[3]
            if path:
                createNewRef = True
                for child in hou.node("/stage").children():
                    if child.name(
                    ) == filename + "_material_ref" and child.parm(
                            "filepath1").eval() == path:
                        child.parm("reload").pressButton()
                        createNewRef = False
                if createNewRef:
                    ref = hou.node("/stage").createNode("reference")
                    ref.setName(filename + "_material_ref", 1)
                    ref.parm("filepath1").set(path)
                    ref.parm("primpath").set("/materials/")

                panes = self.getCurrentNetworkEditorPane()
                paths = []
                for pane in panes:
                    paths.append(pane.pwd())

                hdaPath = path.split(".")[0] + ".hda"
                hou.hda.installFile(hdaPath)

                success = False

                for p in paths:
                    try:
                        for child in p.children():
                            if child.type().name() == re.sub(
                                    r'\W+', '', filename):
                                child.destroy()
                        newMat = p.createNode(re.sub(r'\W+', '', filename))
                        newMat.setName(filename, 1)
                        newMat.setMaterialFlag(True)
                        success = True
                    except:
                        pass

                if not success:
                    for child in hou.node("/mat").children():
                        if child.type().name() == re.sub(r'\W+', '', filename):
                            child.destroy()
                    newMat = hou.node("/mat").createNode(
                        re.sub(r'\W+', '', filename))
                    newMat.setName(filename, 1)
                    newMat.setMaterialFlag(True)

                    qd.message(
                        "Material successfully cloned into /mat context.")

        else:
            qd.error("Nothing was cloned")
コード例 #3
0
    def updateAll(self):
        obj = hou.node("/obj")
        mat = hou.node("/mat")
        for node in obj.allSubChildren():
            if node.isMaterialManager():
                for material in node.children():
                    self.updateOne(material)

        for node in mat.children():
            self.updateOne(node)

        qd.message("Updated all materials")
コード例 #4
0
    def shot_results(self, value):
        shot_name = value[0]

        shot = self.project.get_shot(shot_name)
        if shot is None:
            qd.error("There was a problem loading the shot.")
            return

        prevNum = shot.get_camera_number()
        newNum = prevNum + 1
        shot.set_camera_number(newNum)

        message = "There are now " + str(
            newNum) + " cameras in shot " + shot_name

        qd.message(message)
コード例 #5
0
    def update_shots(self):
        shot_list = ShotgunReader().getShotList()
        #print(shot_list)

        list_file = open(
            os.path.join(self.project.get_shots_dir(), ".shot_list"), "w")
        list_file.truncate(0)
        for shot in shot_list:
            #print("shot " + shot)
            list_file.write(shot + "\n")

            self.create_shot(shot)

        list_file.close()

        qd.message("Shots updated successfully.")
コード例 #6
0
    def update(self):
        layout = LayoutUpdater()
        mat = MatUpdater()

        layout.updateAll()
        mat.updateAll()

        for node in hou.node("/obj").children():
            if node.type().name() == "cenoteCamera" or node.type().name(
            ) == "cenoteAnimation":
                try:
                    node.parm("buildHierarchy").pressButton()
                except Exception as e:
                    print(e)
                    qd.warning("Couldn't update node " + node.name())
        qd.message(
            "Camera and Animation nodes successfully updated. Remember to check your render node camera paths!"
        )
コード例 #7
0
    def go(self):
        #open the layer editor
        pm.Mel.eval("mayaUsdOpenUsdLayerEditor")

        qd.message(
            "Select the USD file in the layer editor window, then hit OK")

        #check if file needs to be saved
        nts = pm.Mel.eval("mayaUsdLayerEditorWindow -q -ns")

        if nts == 0:
            qd.message(
                "No changes were made to the layout. No changes have been saved."
            )
            return

        #save changes made to the layer
        pm.Mel.eval("mayaUsdLayerEditorWindow -e -sv")
コード例 #8
0
    def updateLayout(self, layout):
        print("updating " + layout.name())
        #reload its usd reference node
        self.reloadUsd(layout)
        #update all materials in the layout's library
        lib = None
        for node in layout.children():
            if node.type().name() == "matnet":
                lib = node

        matList = []
        for mat in lib.children():
            self.reloadMaterial(mat)
            matList.append(mat.name())

        #undo all material assignments (set to 0)
        layout.parm("num_materials").set(0)
        #parse through the material bindings again
        matDict = self.getMatDict(layout)
        self.assignMats(layout, matDict, matList, lib)

        qd.message("Successfully updated " + layout.name())
コード例 #9
0
    def options_results(self, options):
        '''for op in options:
            print(op)'''
        anim = options[0]
        layout = options[1]
        lights = options[2]
        fx = options[3]

        isCamera = self.get_camera()
        if not isCamera:
            return

        if anim:
            isAnim = self.get_all_anim()
            if not isAnim:
                qd.message(
                    "There is no animation published for this shot. Continuing to build shot..."
                )

        if layout:
            isLayout = self.get_layout()
            if not isLayout:
                qd.message(
                    "Couldn't clone the layout for this shot. Continuing to build shot..."
                )

        self.sequence_name = self.shot_name[:1]
        self.sequence = self.project.get_sequence(self.sequence_name)

        if lights:
            isLights = self.get_lights()
            if not isLights:
                qd.message(
                    "Couldn't clone sequence lighting. Continuing to build shot..."
                )

        if fx:
            self.get_fx()

        hou.node("/obj").layoutChildren()

        self.build_render()
コード例 #10
0
 def __init__(self):
     self.project = Project()
     qd.message(
         "This action will save a copy of this Maya file in the groups folder, but will not publish "
         + "anything to the pipeline.")