Esempio n. 1
0
    def attrAddClicked(self):
        attr_list = lib_maya_utils.get_selected_maya_attributes()
        if len(attr_list) == 0:
            msg = 'Please select attributes in the channel box, none where found.'
            LOG.warning(msg)
            return
        col = lib_state.get_active_collection()
        if col is None:
            msg = 'Cannot add attributes, active collection is not defined.'
            LOG.warning(msg)
            return
        lib_attr.add_attributes_to_collection(attr_list, col)

        def update_func():
            self.updateAttributeModel()
            self.updateSolveValidState()
            self.setStatusLine(const.STATUS_READY)
            return

        # Add Callbacks
        callback_manager = self.getCallbackManager()
        if callback_manager is not None:
            lib_attr.add_callbacks_to_attributes(
                attr_list,
                update_func,
                callback_manager,
            )

        update_func()
        return
    def addClicked(self):
        """
        Add the selected nodes or node attributes to the data model.
        """
        # Store the selection, in case any tools or callbacks
        # accidentally change the scene selection.
        sel = lib_maya_utils.get_scene_selection()

        s = time.time()
        col = lib_state.get_active_collection()
        if col is None:
            msg = 'Cannot add attributes, active collection is not defined.'
            LOG.warning(msg)
            return
        e = time.time()
        LOG.debug("attribute addClicked1: t=%s", e - s)

        s = time.time()
        attr_list = lib_maya_utils.get_selected_maya_attributes()
        attr_list = lib_maya_utils.input_attributes_filter(attr_list)
        if len(attr_list) == 0:
            attr_list = lib_maya_utils.get_node_default_attributes(sel)
            attr_list = lib_maya_utils.input_attributes_filter(attr_list)
        if len(attr_list) == 0:
            msg = 'Please select nodes or attributes in the channel box.'
            LOG.warning(msg)
            return
        e = time.time()
        LOG.debug("attribute addClicked2: t=%s", e - s)

        s = time.time()
        try:
            mmapi.set_solver_running(True)  # disable selection callback.
            lib_attr.add_attributes_to_collection(attr_list, col)
        finally:
            mmapi.set_solver_running(False)  # enable selection callback
        e = time.time()
        LOG.debug("attribute addClicked3: t=%s", e - s)

        # Restore selection.
        s = time.time()
        lib_maya_utils.set_scene_selection(sel)
        e = time.time()
        LOG.debug("attribute addClicked6: t=%s", e - s)
        return
Esempio n. 3
0
    def addClicked(self):
        """
        Add the selected nodes or node attributes to the data model.
        """
        col = lib_state.get_active_collection()
        if col is None:
            msg = 'Cannot add attributes, active collection is not defined.'
            LOG.warning(msg)
            return

        sel = lib_maya_utils.get_scene_selection()
        attr_list = lib_maya_utils.get_selected_maya_attributes()
        attr_list = lib_maya_utils.input_attributes_filter(attr_list)
        if len(attr_list) == 0:
            attr_list = lib_maya_utils.get_selected_node_default_attributes()
            attr_list = lib_maya_utils.input_attributes_filter(attr_list)
        if len(attr_list) == 0:
            msg = 'Please select nodes or attributes in the channel box.'
            LOG.warning(msg)
            return

        lib_attr.add_attributes_to_collection(attr_list, col)

        def update_func():
            if uiutils.isValidQtObject(self) is False:
                return
            self.dataChanged.emit()
            self.viewUpdated.emit()
            return

        # Add Callbacks
        callback_manager = self.callback_manager
        if callback_manager is not None:
            lib_attr.add_callbacks_to_attributes(
                attr_list,
                update_func,
                callback_manager,
            )

        update_func()

        # Restore selection.
        lib_maya_utils.set_scene_selection(sel)
        return
Esempio n. 4
0
    def attrAddClicked(self):
        col = lib_state.get_active_collection()
        if col is None:
            msg = 'Cannot add attributes, active collection is not defined.'
            LOG.warning(msg)
            return

        sel = lib_maya_utils.get_scene_selection()
        attr_list = lib_maya_utils.get_selected_maya_attributes()
        attr_list = lib_maya_utils.input_attributes_filter(attr_list)
        if len(attr_list) == 0:
            attr_list = lib_maya_utils.get_selected_node_default_attributes()
            attr_list = lib_maya_utils.input_attributes_filter(attr_list)
        if len(attr_list) == 0:
            msg = 'Please select nodes or attributes in the channel box.'
            LOG.warning(msg)
            return

        lib_attr.add_attributes_to_collection(attr_list, col)

        def update_func():
            if uiutils.isValidQtObject(self) is False:
                return
            self.updateAttributeToggleButtons()
            self.updateAttributeColumnVisibility()
            self.updateAttributeModel()
            self.updateSolveValidState()
            return

        # Add Callbacks
        callback_manager = self.getCallbackManager()
        if callback_manager is not None:
            lib_attr.add_callbacks_to_attributes(
                attr_list,
                update_func,
                callback_manager,
            )

        update_func()

        # Restore selection.
        lib_maya_utils.set_scene_selection(sel)
        return
    def addClicked(self):
        """
        Add the selected nodes or node attributes to the data model.
        """
        s = time.time()
        col = lib_state.get_active_collection()
        if col is None:
            msg = 'Cannot add attributes, active collection is not defined.'
            LOG.warning(msg)
            return
        e = time.time()
        LOG.debug("attribute addClicked1: t=%s", e - s)

        s = time.time()
        sel = lib_maya_utils.get_scene_selection()
        attr_list = lib_maya_utils.get_selected_maya_attributes()
        attr_list = lib_maya_utils.input_attributes_filter(attr_list)
        if len(attr_list) == 0:
            attr_list = lib_maya_utils.get_selected_node_default_attributes()
            attr_list = lib_maya_utils.input_attributes_filter(attr_list)
        if len(attr_list) == 0:
            msg = 'Please select nodes or attributes in the channel box.'
            LOG.warning(msg)
            return
        e = time.time()
        LOG.debug("attribute addClicked2: t=%s", e - s)

        s = time.time()
        try:
            mmapi.set_solver_running(True)  # disable selection callback.
            lib_attr.add_attributes_to_collection(attr_list, col)
        finally:
            mmapi.set_solver_running(False)  # enable selection callback
        e = time.time()
        LOG.debug("attribute addClicked3: t=%s", e - s)

        def update_func():
            if uiutils.isValidQtObject(self) is False:
                return
            self.dataChanged.emit()
            self.viewUpdated.emit()
            return

        # Add Callbacks
        s = time.time()
        callback_manager = self.callback_manager
        if callback_manager is not None:
            lib_attr.add_callbacks_to_attributes(
                attr_list,
                update_func,
                callback_manager,
            )
        e = time.time()
        LOG.debug("attribute addClicked4: t=%s", e - s)

        s = time.time()
        update_func()
        e = time.time()
        LOG.debug("attribute addClicked5: t=%s", e - s)

        # Restore selection.
        s = time.time()
        lib_maya_utils.set_scene_selection(sel)
        e = time.time()
        LOG.debug("attribute addClicked6: t=%s", e - s)
        return