def create_control(self, on_selected=False):
        name = str(self.control_name_line_edit.text()).strip()
        shape = self.shape_type_combo.currentText()
        color = self.current_assign_color

        try:
            selected = cmds.ls(selection=True)[0]
        except:
            selected = None

        with UndoContext():
            if on_selected:
                transform_node = cmds.ls(selection=True)[0]
                add_curve_shape(
                    shape_choice=shape,
                    transform_node=transform_node,
                    color=color
                )
                return  # Don't build hierarchy if just adding shape
            else:
                transform_node = cmds.group(empty=True, name=name)
                add_curve_shape(
                    shape_choice=shape,
                    transform_node=transform_node,
                    color=color
                )

            if selected:
                tool.match_transformations(source=selected, target=transform_node)

            if self.use_hierarchy_checkbox.isChecked():
                self.build_hierarchy(control_object=transform_node)
    def create_rig(self):
        name = str(self.name_line_edit.text()).strip()
        if not name:
            return self.popUpError(ValueError('Invalid input for Rig Name!'))

        with UndoContext():
            simple_rig_setup(name)
Beispiel #3
0
    def _get_plugin_node_settings(self):
        node_key = self.plugin_node_type_combo.currentText()
        node_name = str(self.input_plugin_node_name.text()).strip()
        if not node_name:
            node_name = self.plugin_node_type_combo.currentText()

        with UndoContext():
            create_plugin_node(plugin_node_key=node_key, name=node_name)
Beispiel #4
0
    def _get_node_settings(self):
        node_key = node_data.NODE_NAME_DICTIONARY[
            self.node_type_combo.currentText()]
        node_name = str(self.input_node_name.text()).strip()
        if not node_name:
            node_name = self.node_type_combo.currentText()

        with UndoContext():
            create_node(node_key=node_key, name=node_name)
Beispiel #5
0
 def run_create_child(self):
     with UndoContext():
         if self.override_checkbox.checkState():
             suffix = self._get_suffix_parameter()
             for node in cmds.ls(selection=True):
                 create_child(suffix=suffix, input_object=node)
         else:
             for node in cmds.ls(selection=True):
                 create_child(input_object=node)
Beispiel #6
0
    def replace_text(self):
        find_text = str(self.find_line_edit.text()).strip()
        replace_text = str(self.replace_line_edit.text()).strip()

        select_scope = not(self.selected_radio_button.isChecked())

        with UndoContext():
            search_replace_name(
                search_input=find_text,
                replace_output=replace_text,
                hierarchy=select_scope
            )
Beispiel #7
0
    def matrix_constrain(self):
        t = self.translate_checkbox.checkState()
        r = self.rotate_checkbox.checkState()
        s = self.scale_checkbox.checkState()

        source, inverse, target = nUtils.get_selected_nodes()

        with UndoContext():
            matrix_constraint(source=source,
                              inverse=inverse,
                              target=target,
                              position=t,
                              orientation=r,
                              scale=s)
Beispiel #8
0
    def create_pv_solver(self):
        ik_start = str(self.ik_start_line_edit.text()).strip()
        ik_pivot = str(self.ik_pivot_line_edit.text()).strip()
        ik_end = str(self.ik_end_line_edit.text()).strip()

        invalid_objects = [
            obj for obj in (ik_start, ik_pivot, ik_end)
            if not cmds.objExists(obj)
        ]

        if invalid_objects:
            return self.popUpError(
                NameError('No object matches name(s): {}'.format(
                    str(invalid_objects))))

        with UndoContext():
            create_pv_guide(ik_base=ik_start, ik_pivot=ik_pivot, ik_end=ik_end)
Beispiel #9
0
    def create_vector_aim_constraint(self):
        source = str(self.source_line_edit.text()).strip()
        target = str(self.target_line_edit.text()).strip()
        up_vec_text = self.up_vector_line_edit.text().strip()
        try:
            int(up_vec_text[0])
            up_vector = list(up_vec_text)
        except:
            up_vector = str(self.up_vector_line_edit.text())
        aim_axis = self.aim_vector_axis_combo.currentText()
        up_vector_axis = self.up_vector_axis_combo.currentText()

        with UndoContext():
            vector_aim_constraint(source=source,
                                  target=target,
                                  up_position=up_vector,
                                  aim_vector=aim_axis,
                                  up_vector=up_vector_axis)
Beispiel #10
0
    def create_rivet(self):
        # get target from textfield
        # select 2 edges
        target_name = None
        rivet_name = ''
        if self.rivet_object_line_edit.isEnabled():
            target_name = str(self.rivet_object_line_edit.text()).strip()
            if not cmds.objExists(target_name):
                raise NameError('Given name is not a node in the scene!')
        else:
            rivet_name = str(self.rivet_name_line_edit.text()).strip()

        edges = cmds.ls(selection=True, flatten=True)

        with UndoContext():
            create_rivet(input_edges=edges,
                         target=target_name,
                         name=rivet_name)
    def build_hierarchy(self, control_object):
        self.hierarchy_list = []
        # Beta:
        highest_index_key = max(self.offset_hierarchy_inputs_dict.keys()) + 1
        for index in range(highest_index_key):
            hierarchy_widget = self.offset_hierarchy_inputs_dict.get(index)
            if not hierarchy_widget:
                continue
            # Check widget type to call correct text evaluator
            if isinstance(hierarchy_widget, QtWidgets.QComboBox):
                offset_name = str(hierarchy_widget.currentText()).strip()
            elif isinstance(hierarchy_widget, QtWidgets.QLineEdit):
                offset_name = str(hierarchy_widget.text()).strip()

            self.hierarchy_list.append(offset_name)

        with UndoContext():
            for offset in self.hierarchy_list:
                tool.create_offset(suffix=offset, input_object=control_object)
Beispiel #12
0
    def _create_attr_parameters(self):
        attribute_name = str(self.create_attr_line_edit.text()).strip()

        attribute_type = self.attribute_types_dict[
            self.attr_type_combo.currentText()]

        input_object = cmds.ls(selection=True)
        try:
            min_value = float(self.min_value_line_edit.text())
        except ValueError:
            min_value = None
        try:
            max_value = float(self.max_value_line_edit.text())
        except ValueError:
            max_value = None
        default_value = float(self.default_value_line_edit.text())
        keyable = self.attr_keyable_check.isChecked()
        visible = True

        enum_names = []
        for item in self.enum_index_list:
            enum_names.append(str(item.text()).strip())

        if self.attr_type_combo.currentText() == 'Spacer':
            enum_names = ['-------']
            keyable = False

        with UndoContext():
            for obj in input_object:
                create_attr(attribute_name=attribute_name,
                            attribute_type=attribute_type,
                            input_object=obj,
                            min_value=min_value,
                            max_value=max_value,
                            default_value=default_value,
                            keyable=keyable,
                            channelbox=visible,
                            enum_names=enum_names)
Beispiel #13
0
 def publish_mode(self):
     with UndoContext():
         sanityChecker.publishMode()
Beispiel #14
0
 def edit_mode(self):
     with UndoContext():
         sanityChecker.editMode()
Beispiel #15
0
    def _duplicate_node_network(self):
        find_text = str(self.find_name.text()).strip()
        replace_text = str(self.replace_name.text()).strip()

        with UndoContext():
            duplicate_node_connections(find=find_text, replace=replace_text)
Beispiel #16
0
 def run_offset_joint_hierarchy(self):
     with UndoContext():
         joints = cmds.ls(selection=True)
         offset_joint_hierarchy(joints)
 def set_control_color(self):
     nodes = cmds.ls(selection=True)
     with UndoContext():
         for node in nodes:
             set_control_color(rgb_input=self.current_assign_color, input_object=node)
Beispiel #18
0
        text, starting_number, naming_method, upper = \
            self._get_rename_settings()

        if naming_method:
            index_type = True
        else:
            index_type = False

        if upper:
            case = True
        else:
            case = False

        ending = self.list_end_condition_checkbox.isChecked()

        with UndoContext():
            list_renamer(
                new_name=text,
                numeric_index=index_type,
                start_number=starting_number,
                upper_case=case,
                end_name=ending
            )

    def replace_text(self):
        find_text = str(self.find_line_edit.text()).strip()
        replace_text = str(self.replace_line_edit.text()).strip()

        select_scope = not(self.selected_radio_button.isChecked())

        with UndoContext():
Beispiel #19
0
    def edit_suffix(self, add=False, replace=False, remove=False):

        suffix = str(self.suffix_line_edit.text()).strip()

        with UndoContext():
            set_suffix(input_suffix=suffix, add=add, remove=remove, replace=replace)