コード例 #1
0
    def load(self, context, name, namespace, data):

        from avalon.fusion import (imprint_container, get_current_comp,
                                   comp_lock_and_undo_chunk)

        # Fallback to asset name when namespace is None
        if namespace is None:
            namespace = context['asset']['name']

        # Use the first file for now
        path = self._get_first_image(self.fname)

        # Create the Loader with the filename path set
        comp = get_current_comp()
        with comp_lock_and_undo_chunk(comp, "Create Loader"):

            args = (-32768, -32768)
            tool = comp.AddTool("Loader", *args)
            tool["Clip"] = path

            # Set global in point to start frame (if in version.data)
            start = context["version"]["data"].get("startFrame", None)
            if start is not None:
                loader_shift(tool, start, relative=False)

            imprint_container(tool,
                              name=name,
                              namespace=namespace,
                              context=context,
                              loader=self.__class__.__name__)
コード例 #2
0
    def process(self):

        file_format = "TiffFormat"

        comp = fusion.get_current_comp()

        # todo: improve method of getting current environment
        # todo: pref avalon.Session over os.environ

        workdir = os.path.normpath(os.environ["AVALON_WORKDIR"])

        filename = "{}..tiff".format(self.name)
        filepath = os.path.join(workdir, "render", "preview", filename)

        with fusion.comp_lock_and_undo_chunk(comp):
            args = (-32768, -32768)  # Magical position numbers
            saver = comp.AddTool("Saver", *args)
            saver.SetAttrs({"TOOLS_Name": self.name})

            # Setting input attributes is different from basic attributes
            # Not confused with "MainInputAttributes" which
            saver["Clip"] = filepath
            saver["OutputFormat"] = file_format

            # # # Set standard TIFF settings
            if saver[file_format] is None:
                raise RuntimeError("File format is not set to TiffFormat, "
                                   "this is a bug")

            # Set file format attributes
            saver[file_format]["Depth"] = 1  # int8 | int16 | float32 | other
            saver[file_format]["SaveAlpha"] = 0
コード例 #3
0
def duplicate_with_input_connections():
    """Duplicate selected tools with incoming connections."""

    comp = fusion.get_current_comp()
    original_tools = comp.GetToolList(True).values()
    if not original_tools:
        return  # nothing selected

    with fusion.comp_lock_and_undo_chunk(comp,
                                         "Duplicate With Input Connections"):

        # Generate duplicates
        comp.Copy()
        comp.SetActiveTool()
        comp.Paste()
        duplicate_tools = comp.GetToolList(True).values()

        # Copy connections
        for original, new in zip(original_tools, duplicate_tools):

            original_inputs = original.GetInputList().values()
            new_inputs = new.GetInputList().values()
            assert len(original_inputs) == len(new_inputs)

            for original_input, new_input in zip(original_inputs, new_inputs):

                if is_connected(original_input):

                    if is_connected(new_input):
                        # Already connected if it is between the copied tools
                        continue

                    new_input.ConnectTo(original_input.GetConnectedOutput())
                    assert is_connected(new_input), "Must be connected now"
コード例 #4
0
    def __init__(self, parent=None):
        QtWidgets.QWidget.__init__(self, parent)

        self._comp = avalon.get_current_comp()
        self._comp_name = self._get_comp_name()

        self.setWindowTitle("Set Render Mode")
        self.setFixedSize(300, 175)

        layout = QtWidgets.QVBoxLayout()

        # region comp info
        comp_info_layout = QtWidgets.QHBoxLayout()

        update_btn = QtWidgets.QPushButton(
            qtawesome.icon("fa.refresh", color="white"), "")
        update_btn.setFixedWidth(25)
        update_btn.setFixedHeight(25)

        comp_information = QtWidgets.QLineEdit()
        comp_information.setEnabled(False)

        comp_info_layout.addWidget(comp_information)
        comp_info_layout.addWidget(update_btn)
        # endregion comp info

        # region modes
        mode_options = QtWidgets.QComboBox()
        mode_options.addItems(_help.keys())

        mode_information = QtWidgets.QTextEdit()
        mode_information.setReadOnly(True)
        # endregion modes

        accept_btn = QtWidgets.QPushButton("Accept")

        layout.addLayout(comp_info_layout)
        layout.addWidget(mode_options)
        layout.addWidget(mode_information)
        layout.addWidget(accept_btn)

        self.setLayout(layout)

        self.comp_information = comp_information
        self.update_btn = update_btn

        self.mode_options = mode_options
        self.mode_information = mode_information

        self.accept_btn = accept_btn

        self.connections()
        self.update()

        # Force updated render mode help text
        self._update_rendermode_info()
コード例 #5
0
    def process(self, context):
        """Collect all image sequence tools"""

        current_comp = fusion.get_current_comp()
        assert current_comp, "Must have active Fusion composition"
        context.data["currentComp"] = current_comp

        # Store path to current file
        filepath = current_comp.GetAttrs().get("COMPS_FileName", "")
        context.data['currentFile'] = filepath
コード例 #6
0
    def update(self):
        """Update all information in the UI"""

        self._comp = avalon.get_current_comp()
        self._comp_name = self._get_comp_name()
        self.comp_information.setText(self._comp_name)

        # Update current comp settings
        mode = self._get_comp_rendermode()
        index = self.mode_options.findText(mode)
        self.mode_options.setCurrentIndex(index)
コード例 #7
0
def update_loader_ranges():
    comp = fusion.get_current_comp()
    with fusion.comp_lock_and_undo_chunk(comp, "Reload clip time ranges"):
        tools = comp.GetToolList(True, "Loader").values()
        for tool in tools:

            # Get tool attributes
            tool_a = tool.GetAttrs()
            clipTable = tool_a['TOOLST_Clip_Name']
            altclipTable = tool_a['TOOLST_AltClip_Name']
            startTime = tool_a['TOOLNT_Clip_Start']
            old_global_in = tool.GlobalIn[comp.CurrentTime]

            # Reapply
            for index, _ in clipTable.items():
                time = startTime[index]
                tool.Clip[time] = tool.Clip[time]

            for index, _ in altclipTable.items():
                time = startTime[index]
                tool.ProxyFilename[time] = tool.ProxyFilename[time]

            tool.GlobalIn[comp.CurrentTime] = old_global_in
コード例 #8
0
from avalon.fusion import comp_lock_and_undo_chunk
from avalon import fusion

comp = fusion.get_current_comp()


def main():
    """Set all backgrounds to 32 bit"""
    with comp_lock_and_undo_chunk(comp, 'Backgrounds to 32bit'):
        tools = comp.GetToolList(False, "Background").values()
        for tool in tools:
            tool.Depth = 5


main()