Exemplo n.º 1
0
    def proceed(self, labelname):
        """Place the selected objects in the chosen group or ungroup them.

        Parameters
        ----------
        labelname: str
            The passed string with the name of the group.
            It puts the selected objects inside this group.
        """
        # Deactivate the source command of the `DraftToolBar` class
        # so that it doesn't do more with this command.
        self.ui.sourceCmd = None

        # If the selected group matches the ungroup label,
        # remove the selection from all groups.
        if labelname == self.ungroup:
            for obj in Gui.Selection.getSelection():
                try:
                    groups.ungroup(obj)
                except Exception:
                    pass
        else:
            # Otherwise try to add all selected objects to the chosen group
            if labelname in self.labels:
                i = self.labels.index(labelname)
                g = self.doc.getObject(self.groups[i])
                for obj in Gui.Selection.getSelection():
                    try:
                        g.addObject(obj)
                    except Exception:
                        pass
Exemplo n.º 2
0
    def proceed(self, labelname):
        """Place the selected objects in the chosen group or ungroup them.
        Parameters
        ----------
        labelname: str
            The passed string with the name of the group.
            It puts the selected objects inside this group.
        """
        # If the selected group matches the ungroup label,
        # remove the selection from all groups.
        if labelname == self.ungroup:
            for obj in Gui.Selection.getSelection():
                try:
                    groups.ungroup(obj)
                except Exception:
                    pass
        else:
            # Deactivate the source command of the `DraftToolBar` class
            # so that it doesn't do more with this command.
            self.ui.sourceCmd = None

            #if new group is selected then launch AddNamedGroup
            if labelname == self.addNewGroupStr:
                add = AddNamedGroup()
                add.Activated()
            else:
                #else add selection to the selected group
                if labelname in self.labels:
                    i = self.labels.index(labelname)
                    g = self.doc.getObject(self.groups[i])
                    moveToGroup(g)