def Activated(self):
        try:
            s = Gui.Selection.getSelectionEx()
            if len(s) > 1 or len(s) < 1:
                # TODO: FIXME: Should we accept more than one object?
                errMessage = "Select one object"
                faced.errorDialog(errMessage)
                return
            DivideBy = QtGui.QInputDialog.getInt(None, "Divide by", "Input:",
                                                 0, 1, 50.0, 1)[0]
            if (DivideBy <= 1):
                return  # nothing to do here
            self.selected = s[0]
            App.ActiveDocument.openTransaction(
                translate("Design456", "Divide Circle"))
            edgesToRecreate = self.findEdgeHavingCurve()
            #We have the edges that needs to be divided
            newObjects = self.recreateEdges(edgesToRecreate, DivideBy)
            App.ActiveDocument.removeObject(self.selected.Object.Name)
            App.ActiveDocument.commitTransaction()  # undo
            return newObjects

        except Exception as err:
            App.Console.PrintError("'Design456_DivideCircleFace' Failed. "
                                   "{err}\n".format(err=str(err)))
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)
Exemple #2
0
    def Activated(self):
        import ThreeDWidgets.fr_coinwindow as win
        self.selectedObj.clear()
        sel = Gui.Selection.getSelectionEx()
        if len(sel) < 2:
            # An object must be selected
            errMessage = "Select at least two objects to Align them"
            faced.errorDialog(errMessage)
            return

        self.selectedObj = sel
        self.recreateAll()
        self.smartInd = Fr_Align_Widget(self.NewBoundary, ["Align Tool", ])

        self.smartInd.w_callback_ = callback_release
        self.smartInd.w_btnCallbacks_ = [callback_btn0,
                                callback_btn1,
                                callback_btn2,
                                callback_btn3,
                                callback_btn4,
                                callback_btn5,
                                callback_btn6,
                                callback_btn7,
                                callback_btn8]

        self.smartInd.w_userData.callerObject = self

        if self._mywin is None:
            self._mywin = win.Fr_CoinWindow()
        self._mywin.addWidget(self.smartInd)
        mw = self.getMainWindow()
        self._mywin.show()
Exemple #3
0
    def Activated(self):
        import random
        try:
            sel = Gui.Selection.getSelection()  # selection object
            if len(sel) == 0:
                errmsg = "Please select an object to apply the tool"
                faced.errorDialog(errmsg)
                return

            for selectedObj in sel:
                App.ActiveDocument.openTransaction(
                    translate("Design456", "Colorize"))
                colors = []
                for ii in range(len(selectedObj.Shape.Faces)):
                    base = random.uniform(
                        0.3, 0.7)  # Randomize even the lower limit
                    colors.append((random.uniform(base,
                                                  1), random.uniform(base, 1),
                                   random.uniform(base, 1),
                                   0.0))  #red, green, blue, transparency
                selectedObj.ViewObject.DiffuseColor = colors
                App.ActiveDocument.commitTransaction()  #undo reg.

        except Exception as err:
            App.Console.PrintError("'Design_ColorizeObject' Failed. "
                                   "{err}\n".format(err=str(err)))
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)
Exemple #4
0
    def Activated(self):
        s = Gui.Selection.getSelectionEx()
        if len(s) < 1:
            # An object must be selected
            errMessage = "Select an object before using the tool"
            faced.errorDialog(errMessage)
            return
        try:
            self.selectedObjects = s
            self.w_vector = s[0].Object.Placement.Base
            self.discObj = Fr_ThreeArrows_Widget(
                [self.w_vector, App.Vector(0, 0, 0)],  #
                # label
                [
                    (str(round(self.w_rotation[0], 2)) + "°" +
                     str(round(self.w_rotation[1], 2)) + "°" +
                     str(round(self.w_rotation[2], 2)) + "°"),
                ],
                FR_COLOR.FR_WHITE,  # lblcolor
                [FR_COLOR.FR_RED, FR_COLOR.FR_GREEN, FR_COLOR.FR_BLUE
                 ],  # arrows color
                # rotation of the disc main
                [0, 0, 0, 0],
                self.setupRotation,  # setup rotation
                [30.0, 30.0, 30.0],  # scale
                1,  # type
                0,  # opacity
                10)  # distance between them
            self.discObj.enableDiscs()

            # Different callbacks for each action.
            self.discObj.w_xAxis_cb_ = self.MouseDragging_cb
            self.discObj.w_yAxis_cb_ = self.MouseDragging_cb
            self.discObj.w_zAxis_cb_ = self.MouseDragging_cb

            self.discObj.w_discXAxis_cb_ = self.RotatingObject_cb
            self.discObj.w_discYAxis_cb_ = self.RotatingObject_cb
            self.discObj.w_discZAxis_cb_ = self.RotatingObject_cb

            self.discObj.w_callback_ = self.callback_release
            self.discObj.w_userData.callerObject = self

            self.COIN_recreateObject()

            if self._mywin is None:
                self._mywin = win.Fr_CoinWindow()

            self._mywin.addWidget(self.discObj)
            mw = self.getMainWindow()
            self._mywin.show()

        except Exception as err:
            App.Console.PrintError("'Activated SmartMove' Failed. "
                                   "{err}\n".format(err=str(err)))
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)
 def Activated(self):
     try:
         s = Gui.Selection.getSelectionEx()
         if (len(s) < 1):
             # Two object must be selected
             errMessage = "Select two or more objects to use Shell Tool"
             faced.errorDialog(errMessage)
             return
         App.ActiveDocument.openTransaction(
             translate("Design456", "Part Shell"))
         thickness = QtGui.QInputDialog.getDouble(None, "Thickness",
                                                  "Value:", 0, -1000.0,
                                                  1000.0, 2)[0]
         if (thickness == 0):
             return  # Nothing to do
         allObjects = []
         for o in s:
             allObjects.append(App.ActiveDocument.getObject(o.ObjectName))
         currentObj = App.ActiveDocument.getObject(s[0].ObjectName)
         currentObjLink = currentObj.getLinkedObject(True)
         thickObj = App.ActiveDocument.addObject("Part::Thickness",
                                                 "Thickness")
         thickObj.Value = thickness
         thickObj.Join = 0
         thickObj.Mode = 0
         thickObj.Intersection = False
         thickObj.SelfIntersection = False
         getfacename = faced.getFaceName(s[0])
         thickObj.Faces = (
             currentObj,
             getfacename,
         )
         if thickObj.isValid() is False:
             App.ActiveDocument.removeObject(thickObj.Name)
             # Shape != OK
             errMessage = "Failed create shell"
             faced.errorDialog(s, errMessage)
         else:
             App.ActiveDocument.recompute()
             NewJ = App.ActiveDocument.addObject(
                 'Part::Feature', 'Shell').Shape = thickObj.Shape
             App.ActiveDocument.recompute()
             # Remove Old objects
             for obj in allObjects:
                 App.ActiveDocument.removeObject(obj.Name)
             App.ActiveDocument.removeObject(thickObj.Name)
         App.ActiveDocument.commitTransaction()  #undo reg.
         App.ActiveDocument.recompute()
         del allObjects[:]
     except Exception as err:
         App.Console.PrintError("'Part::Shell' Failed. "
                                "{err}\n".format(err=str(err)))
         exc_type, exc_obj, exc_tb = sys.exc_info()
         fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
         print(exc_type, fname, exc_tb.tb_lineno)
    def Activated(self):
        try:
            App.ActiveDocument.openTransaction(
                translate("Design456", "Arc3points"))
            oneObject = False
            selected = Gui.Selection.getSelectionEx()
            selectedOne1 = Gui.Selection.getSelectionEx()[0]
            selectedOne2 = Gui.Selection.getSelectionEx()[0]
            selectedOne3 = Gui.Selection.getSelectionEx()[0]
            allSelected = []
            if ((len(selected) < 3 or len(selected) > 3)
                    and (selectedOne1.HasSubObjects is False
                         or selectedOne2.HasSubObjects is False
                         or selectedOne3.HasSubObjects is False)):
                # Two object must be selected
                errMessage = "Select two or more objects to useArc3Points Tool"
                faced.errorDialog(errMessage)
                return
            if selectedOne1.HasSubObjects and len(selected) == 1:
                # We have only one object that we take vertices from
                oneObject = True
                subObjects = selected[0].SubObjects
                for n in subObjects:
                    allSelected.append(n.Point)
            elif len(selected) == 3:
                for t in selected:
                    allSelected.append(
                        t.Object.Shape.Vertexes[0].Placement.Base)
            else:
                oneObject = False
                print("A combination of objects")
                print("Not implemented")
                return
            C1 = _part.Arc(App.Vector(allSelected[0]),
                           App.Vector(allSelected[1]),
                           App.Vector(allSelected[2]))
            S1 = _part.Shape([C1])
            W = _part.Wire(S1.Edges)
            _part.show(W)
            App.ActiveDocument.recompute()
            App.ActiveDocument.ActiveObject.Label = "Arc_3_Points"
            # Remove only if it != one object
            if oneObject is False:
                for n in selected:
                    App.ActiveDocument.removeObject(n.ObjectName)
            del allSelected[:]
            App.ActiveDocument.recompute()
            App.ActiveDocument.commitTransaction()  # undo

        except Exception as err:
            App.Console.PrintError("'Arc3Points' Failed. "
                                   "{err}\n".format(err=str(err)))
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)
 def refreshSelection(self):
     self.selectedObj=Gui.Selection.getSelectionEx()
     self.faces=self.selectedObj[0].Object.Shape.Faces
     self.edges=self.selectedObj[0].Object.Shape.Edges
     self.vertexes=self.selectedObj[0].Object.Shape.Vertexes
     self.Targetobj = self.selectedObj[0].Object
     self.doc=App.ActiveDocument
     if len(self.selectedObj)== 0:
         # An object must be selected
         errMessage = "Select an object, one face or one edge before using the tool"
         faced.errorDialog(errMessage)
         return
    def Activated(self):
        try:
            App.ActiveDocument.openTransaction(
                translate("Design456", "MultipointsToWire"))
            selected = Gui.Selection.getSelectionEx()

            if (len(selected) < 2):
                # Two object must be selected
                if (not selected[0].HasSubObjects):
                    errMessage = "Select two or more objects to use MultiPointsToLineOpen Tool"
                    faced.errorDialog(errMessage)
                    return

            allSelected = []
            for t in selected:
                if type(t) == list:
                    for tt in t:
                        allSelected.append(
                            App.Vector(tt.Shape.Vertexes[0].Point))
                else:
                    if t.HasSubObjects and hasattr(t.SubObjects[0],
                                                   "Vertexes"):
                        for v in t.SubObjects:
                            allSelected.append(App.Vector(v.Point))
                    elif t.HasSubObjects and hasattr(t.SubObjects[0],
                                                     "Surface"):
                        errMessage = "Only Vertexes are allowed. You selected a face"
                        faced.errorDialog(errMessage)
                        return
                    else:
                        allSelected.append(App.Vector(t.Object.Shape.Point))

            if self.type == 0:
                Wire1 = _draft.makeWire(allSelected, closed=True)
            else:
                Wire1 = _draft.makeWire(allSelected, closed=False)
            """
            I have to find a way to avoid deleting Vertices if they are a part from another object.
            This is disabled at the moment.

            for n in selected:
                App.ActiveDocument.removeObject(n.Object.Name)
            """
            del allSelected[:]
            App.ActiveDocument.recompute()
            App.ActiveDocument.commitTransaction()  # undo

        except Exception as err:
            App.Console.PrintError("'MultiPointsToWire' Failed. "
                                   "{err}\n".format(err=str(err)))
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)
    def Activated(self):
        try:
            AllObjects = []
            self.extrusionLength = -(QtGui.QInputDialog.getDouble(
                None, "Extrusion Length", "Length:", 0, -10000.0, 10000.0,
                2)[0])
            if self.extrusionLength == 0.0:
                return

            self.selectedObj = Gui.Selection.getSelectionEx()
            if (len(self.selectedObj) < 1):
                # An object must be selected
                errMessage = "Select a face to use Extrude"
                faced.errorDialog(errMessage)
                return
            if len(self.selectedObj) == 1:
                # It is only one object. But might have different faces
                if (self.selectedObj[0].HasSubObjects):
                    # Here it can be a face with multiple faces
                    # Or a 3D object with multiple faces?
                    result = self.selectedObj[0].SubObjects
                    AllObjects = self.ExtractFace(result)
                else:
                    # Only One object that doesn't have subobjects
                    if isinstance(self.selectedObj[0].Object.Shape, Part.Face):
                        # It is a face. i.e. the object itself is a face only
                        AllObjects = [self.selectedObj[0]]
                    else:
                        # It is a face of a 3D object
                        AllObjects = [self.ExtractFace()]
            else:
                # We have multiple objects selected. Could be faces, 3D objects
                # or mixed
                result = []
                result.clear()
                for i in range(0, len(self.selectedObj)):
                    _obj = self.selectedObj[i]
                    if (hasattr(_obj, "HasSubObjects")):
                        if (_obj.HasSubObjects):
                            for nobj in _obj.SubObjects:
                                if type(nobj) == Part.Face:
                                    result.append(nobj)
                        else:
                            result.append(_obj)
                AllObjects = self.ExtractFace(result)
            self.ExtrudeFace(AllObjects)
        except Exception as err:
            App.Console.PrintError("'Design456_Extrude' Failed. "
                                   "{err}\n".format(err=str(err)))
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)
    def Activated(self):
        mergedObj = None
        try:
            s = Gui.Selection.getSelectionEx()
            if (len(s) < 2):
                # Two object must be selected
                errMessage = "Select two or more objects to Merge"
                faced.errorDialog(errMessage)
                return
            App.ActiveDocument.openTransaction(
                translate("Design456", "Part Merge"))
            allObjects = []
            for o in s:
                allObjects.append(App.ActiveDocument.getObject(o.ObjectName))

            newObj = App.ActiveDocument.addObject("Part::MultiFuse",
                                                  "MergedTemp")
            newObj.Shapes = allObjects
            newObj.Refine = True
            App.ActiveDocument.recompute()
            if newObj.isValid() is False:
                App.ActiveDocument.removeObject(newObj.Name)
                # Shape != OK
                errMessage = "Failed Merge"
                faced.errorDialog(errMessage)
            else:

                # Make a simple copy
                newShape = Part.getShape(newObj,
                                         '',
                                         needSubElement=False,
                                         refine=True)
                mergedObj = App.ActiveDocument.addObject(
                    'Part::Feature', 'Merged')
                mergedObj.Shape = newShape
                App.ActiveDocument.recompute()
                # Remove Old objects
                for obj in allObjects:
                    App.ActiveDocument.removeObject(obj.Name)
                App.ActiveDocument.removeObject(newObj.Name)
                App.ActiveDocument.commitTransaction()  #undo reg.
            App.ActiveDocument.recompute()
            del allObjects[:]
            return mergedObj

        except Exception as err:
            App.Console.PrintError("'Part::Merge' Failed. "
                                   "{err}\n".format(err=str(err)))
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)
    def Activated(self, input_object=None):
        try:

            import BOPTools.JoinFeatures
            s = Gui.Selection.getSelection()
            ss = None
            if input_object == None:
                if (len(s) < 1):
                    # One object must be selected at least
                    errMessage = "Select a face or an edge use Chamfer"
                    faced.errorDialog(errMessage)
                    return None
            else:
                s = input_object
            if type(s) == list:
                if len(s) == 1:
                    ss = [s[0]]
                else:
                    ss = [s]
            else:
                ss = [s]
            result = []
            App.ActiveDocument.openTransaction(
                translate("Design456", "SimplifyCompound"))
            for obj in ss:
                #connect Object
                con = BOPTools.JoinFeatures.makeConnect(name='tempConnect')
                con.Objects = [obj]
                con.Refine = True
                con.Tolerance = 0.0
                con.Proxy.execute(con)
                con.purgeTouched()
                #simple copy of connect.
                newShape = con.Shape.copy()
                newPart = App.ActiveDocument.addObject('Part::Feature',
                                                       "Simplified")
                newPart.Shape = newShape
                App.ActiveDocument.recompute()

                App.ActiveDocument.removeObject(con.Name)
                App.ActiveDocument.removeObject(obj.Name)
                result.append(newPart)
            App.ActiveDocument.commitTransaction()  # undo
            return result

        except Exception as err:
            App.Console.PrintError("'SimplifyCompound' Failed. "
                                   "{err}\n".format(err=str(err)))
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)
 def Activated(self):
     try:
         s = Gui.Selection.getSelectionEx()
         if (len(s) < 2):
             # Two object must be selected
             errMessage = "Select two or more objects to Subtract"
             faced.errorDialog(errMessage)
             return
         App.ActiveDocument.openTransaction(
             translate("Design456", "Part Subtract"))
         newObj = App.ActiveDocument.addObject("Part::Cut", "tempSubtract")
         newObj.Base = App.ActiveDocument.getObject(
             s[0].ObjectName)  # Target  must be Application object
         newObj.Tool = App.ActiveDocument.getObject(
             s[1].ObjectName
         )  # Subtracted shape/object must be Application object
         App.ActiveDocument.recompute()
         newObj.Refine = True
         App.ActiveDocument.recompute()
         # Make a simple copy
         newShape = Part.getShape(newObj,
                                  '',
                                  needSubElement=False,
                                  refine=False)
         NewJ = App.ActiveDocument.addObject('Part::Feature',
                                             'Subtract').Shape = newShape
         App.ActiveDocument.recompute()
         if newObj.isValid() is False:
             App.ActiveDocument.removeObject(NewJ.Name)
             # Shape != OK
             errMessage = "Failed to subtract objects"
             faced.errorDialog(errMessage)
         else:
             # Remove Old objects
             allObjects = []
             for o in s:
                 allObjects.append(
                     App.ActiveDocument.getObject(o.ObjectName))
             for obj in allObjects:
                 App.ActiveDocument.removeObject(obj.Name)
             App.ActiveDocument.removeObject(newObj.Name)
         App.ActiveDocument.commitTransaction()  #undo reg.
         App.ActiveDocument.recompute()
         del allObjects[:]
     except Exception as err:
         App.Console.PrintError("'Part::Subtract' Failed. "
                                "{err}\n".format(err=str(err)))
         exc_type, exc_obj, exc_tb = sys.exc_info()
         fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
         print(exc_type, fname, exc_tb.tb_lineno)
Exemple #13
0
    def Activated(self):
        import ThreeDWidgets.fr_coinwindow as win
        self.selectedObj.clear()
        sel = Gui.Selection.getSelectionEx()
        if len(sel) == 0:
            # An object must be selected
            errMessage = "Select an object, one face or one edge to chamfer"
            faced.errorDialog(errMessage)
            return

        self.selectedObj.append(sel[0])
        self.Originalname = self.selectedObj[0].Object.Name

        # Find Out shapes type.
        self.registerShapeType()
        o = Gui.ActiveDocument.getObject(self.selectedObj[0].Object.Name)

        # Undo
        App.ActiveDocument.openTransaction(
            translate("Design456", "SmartFillet"))
        o.Transparency = 80
        self.reCreatechamferObject()

        # get rotation
        rotation = self.getArrowPosition()

        self.smartInd = Fr_Arrow_Widget(
            [self._vector, App.Vector(0.0, 0.0, 0.0)],  # w_vector
            [
                "Radius: 0.0",
            ],
            1,  # Label, linewidth
            FR_COLOR.FR_RED,
            FR_COLOR.FR_WHITE,  # color, lblcolor
            rotation,  # rotation
            [1.0, 1.0, 1.0],  # scale 
            0,  # type
            0.0)  # opacity
        self.smartInd.w_callback_ = callback_release
        self.smartInd.w_move_callback_ = callback_move
        self.smartInd.w_userData.callerObject = self
        self.saveFirstPostion = self._vector
        if self._mywin is None:
            self._mywin = win.Fr_CoinWindow()
        self._mywin.addWidget(self.smartInd)
        mw = self.getMainWindow()
        self._mywin.show()
    def Activated(self):
        try:

            s = Gui.Selection.getSelectionEx()
            if len(s) > 1:
                # TODO: FIXME: Should we accept more than one object?
                errMessage = "Select edges from one object"
                faced.errorDialog(errMessage)
                return
            App.ActiveDocument.openTransaction(
                translate("Design456", "SimplifyEdges"))
            selObj = s[0]
            selEdges = selObj.Object.Shape.OrderedEdges
            selVertexes = []
            for e in selEdges:
                for v in e.Vertexes:
                    selVertexes.append(v.Point)

            # To eliminate multiple vertices
            # incide the same edge, we take only
            # first and last entities and then
            # we make a line and convert it to
            # an edge. which should replace the
            # old edge
            v1 = selVertexes[0]
            v2 = selVertexes[len(selVertexes) - 1]
            l1 = _draft.makeLine(v1, v2)
            App.ActiveDocument.recompute()
            newobj = App.ActiveDocument.addObject("Part::Feature", "Wire")
            sh = l1.Shape
            newobj.Shape = sh.copy()
            App.ActiveDocument.recompute()
            App.ActiveDocument.removeObject(selObj.Object.Name)
            App.ActiveDocument.removeObject(l1.Name)
            App.ActiveDocument.commitTransaction()  # undo

        except Exception as err:
            App.Console.PrintError("'Design456_SimplifyEdges' Failed. "
                                   "{err}\n".format(err=str(err)))
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)
 def Activated(self):
     try:
         s = Gui.Selection.getSelectionEx()
         App.ActiveDocument.openTransaction(
             translate("Design456", "Part Intersect"))
         if (len(s) < 2):
             # Two object must be selected
             errMessage = "Select two or more objects to Intersect"
             faced.errorDialog(errMessage)
             return
         newObj = App.ActiveDocument.addObject("Part::MultiCommon",
                                               "tempIntersect")
         newObj.Shapes = [
             App.ActiveDocument.getObject(s[0].ObjectName),
             App.ActiveDocument.getObject(s[1].ObjectName)
         ]
         App.ActiveDocument.recompute()
         # Make a simple copy
         newShape = Part.getShape(newObj,
                                  '',
                                  needSubElement=False,
                                  refine=False)
         NewJ = App.ActiveDocument.addObject('Part::Feature',
                                             'Intersect').Shape = newShape
         App.ActiveDocument.recompute()
         # Remove Old objects
         allObjects = []
         for o in s:
             allObjects.append(App.ActiveDocument.getObject(o.ObjectName))
         for obj in allObjects:
             App.ActiveDocument.removeObject(obj.Name)
         App.ActiveDocument.removeObject(newObj.Name)
         App.ActiveDocument.commitTransaction()  #undo reg.
         App.ActiveDocument.recompute()
         del allObjects[:]
     except Exception as err:
         App.Console.PrintError("'Part::Intersect' Failed. "
                                "{err}\n".format(err=str(err)))
         exc_type, exc_obj, exc_tb = sys.exc_info()
         fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
         print(exc_type, fname, exc_tb.tb_lineno)
 def Activated(self):
     try:
         objectCreate = False
         newobj = None
         s = Gui.Selection.getSelectionEx()
         if (len(s) < 1):
             # An object must be selected
             errMessage = "Select a face from an object to use Extract"
             faced.errorDialog(errMessage)
             return
         App.ActiveDocument.openTransaction(
             translate("Design456", "Extract a Face"))
         for o in s:
             objName = o.ObjectName
             sh = o.Object.Shape.copy()
             if hasattr(o.Object, "getGlobalPlacement"):
                 gpl = o.Object.getGlobalPlacement()
                 sh.Placement = gpl
             for name in o.SubElementNames:
                 fullname = objName + "_" + name
                 newobj = o.Document.addObject("Part::Feature", fullname)
                 newobj.Shape = sh.getElement(name)
                 objectCreate = True
         App.ActiveDocument.commitTransaction()
         App.ActiveDocument.recompute()
         if newobj.isValid() == False:
             if objectCreate == True:
                 App.ActiveDocument.removeObject(newobj.Name)
             # Shape != OK
             errMessage = "Failed to extract the face"
             faced.errorDialog(errMessage)
             return
     except Exception as err:
         App.Console.PrintError("'Design456_Extract' Failed. "
                                "{err}\n".format(err=str(err)))
         exc_type, exc_obj, exc_tb = sys.exc_info()
         fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
         print(exc_type, fname, exc_tb.tb_lineno)
    def Activated(self):
        try:
            s = Gui.Selection.getSelectionEx()
            if (len(s) < 1):
                # One object must be selected at least
                errMessage = "Select a face or an edge use Chamfer"
                faced.errorDialog(errMessage)
                return
            App.ActiveDocument.openTransaction(
                translate("Design456", "Part Chamfer"))
            Radius = QtGui.QInputDialog.getDouble(None, "Radius", "Radius:", 0,
                                                  -10000.0, 10000.0, 2)[0]
            if (Radius == 0):
                return  # Nothing to do here
            sub1 = s[0]
            tempNewObj = App.ActiveDocument.addObject("Part::Chamfer",
                                                      "tempChamfer")
            tempNewObj.Base = sub1.Object
            names = sub1.SubElementNames
            EdgesToBeChanged = []
            if (len(names) != 0):
                for name in names:
                    edgeNumbor = int(name[4:len(name)])
                    EdgesToBeChanged.append((edgeNumbor, Radius, Radius))
                tempNewObj.Edges = EdgesToBeChanged
            else:
                errMessage = "Chamfer failed. No subelements found"
                faced.errorDialog(errMessage)
                return
            # Make a simple copy of the object
            App.ActiveDocument.recompute()
            if tempNewObj.isValid() is False:
                App.ActiveDocument.removeObject(tempNewObj.Name)
                # Shape != OK
                errMessage = "Failed to fillet the objects"
                faced.errorDialog(errMessage)
            else:
                newShape = Part.getShape(tempNewObj,
                                         '',
                                         needSubElement=False,
                                         refine=False)
                newObj = App.ActiveDocument.addObject(
                    'Part::Feature', 'Chamfer').Shape = newShape
                App.ActiveDocument.recompute()
                App.ActiveDocument.ActiveObject.Label = 'Chamfer'

                App.ActiveDocument.removeObject(sub1.Object.Name)
                App.ActiveDocument.removeObject(tempNewObj.Name)
            del EdgesToBeChanged[:]
            App.ActiveDocument.commitTransaction()  #undo reg.
            App.ActiveDocument.recompute()

        except Exception as err:
            App.Console.PrintError("'Chamfer' Failed. "
                                   "{err}\n".format(err=str(err)))
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)
    def Activated(self):
        try:
            select = Gui.Selection.getSelection()
            if len(select) != 1:
                # Only one object must be selected
                errMessage = "Select one object to scale"
                faced.errorDialog(errMessage)
                return
            # Undo
            self.getXYZdimOfSelectedObject(select[0])

            # Create a tab and show it
            # TODO : I don't know how to give focus to the tab
            mw = self.getMainWindow()
            mw.show()

        # we have a selected object. Try to show the dimensions.
        except Exception as err:
            App.Console.PrintError("'Design456_SmartScale' Failed. "
                                   "{err}\n".format(err=str(err)))
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)
Exemple #19
0
    def Activated(self):
        try:

            s = Gui.Selection.getSelectionEx()
            if (len(s) < 2):
                # Two object must be selected
                errMessage = "Select two or more objects to use Magnet Tool"
                faced.errorDialog(errMessage)
                return
            App.ActiveDocument.openTransaction(translate(
                "Design456", "Magnet"))
            sub1 = s[0]
            sub2 = s[1]
            face1 = faced.getObjectFromFaceName(sub1, sub1.SubElementNames[0])
            face2 = faced.getObjectFromFaceName(sub2, sub2.SubElementNames[0])
            #App.DraftWorkingPlane.alignToFace(face1)

            sub2.Object.Placement.Base = face1.Placement.Base  #face1.CenterOfMass
            sub2.Object.Placement.Base.z = face1.CenterOfMass.z
            # This will fail if the surface doesn't have Rotation
            if (hasattr(face1.Faces[0].Surface, "Rotation")):
                sub2.Object.Placement.Rotation = face1.Faces[
                    0].Surface.Rotation
            else:
                # Don't know what todo . Don't let it be empty.
                # TODO: Find a solution for this.
                sub2.Object.Placement.Rotation.Aixs = App.Vector(0, 0, 1)
                sub2.Object.Placement.Rotation.Angle = 0
            App.ActiveDocument.commitTransaction()  # undo
            App.ActiveDocument.recompute()

        except Exception as err:
            App.Console.PrintError("'Magnet' Failed. "
                                   "{err}\n".format(err=str(err)))
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)
    def Activated(self):
        try:
            s = Gui.Selection.getSelectionEx()
            if (len(s) < 2):
                # Two object must be selected
                #App.ActiveDocument.openTransaction(translate("Design456","Part Group")) TODO: Doesn't work
                errMessage = "Select two or more objects to create a group"
                faced.errorDialog(errMessage)
                return

            newObj = App.ActiveDocument.Tip = App.ActiveDocument.addObject(
                'App::Part', 'Group')
            newObj.Label = 'Group'
            for obj_ in s:
                obj = App.ActiveDocument.getObject(obj_.ObjectName)
                newObj.addObject(obj)
            #App.ActiveDocument.commitTransaction() #undo reg.
            App.ActiveDocument.recompute()
        except Exception as err:
            App.Console.PrintError("'Part::Part' Failed. "
                                   "{err}\n".format(err=str(err)))
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)
Exemple #21
0
    def runClass(self):
        try:
            sel = Gui.Selection.getSelectionEx()
            if (len(sel) < 1 or len(sel) > 1 or len(
                    Gui.Selection.getSelectionEx()[0].SubElementNames) == 0):
                # Two object must be selected
                errMessage = "Select a face to use LoftOnDirection Tool"
                faced.errorDialog(errMessage)
                return

            selectedEdge = Gui.Selection.getSelectionEx()[0].SubObjects[
                0]  # select one element
            SubElementName = Gui.Selection.getSelectionEx(
            )[0].SubElementNames[0]

            #### configuration ####
            ValueLength = -(float)(self.inLength.value())
            ValueScaleX = (float)(self.inScaleX.value())
            ValueScaleY = (float)(self.inScaleY.value())
            ValueScaleZ = (float)(self.inScaleZ.value())

            ####
            createAxis = self.chkAxis.isChecked()  # 0 = not Axis, other = Axis
            createLoft = self.chkLoft.isChecked()  # 0 = not loft, other = loft
            #### configuration ####
            App.ActiveDocument.openTransaction(
                translate("Design456", "LoftOnDirection"))
            if hasattr(selectedEdge, 'Surface'):
                plr = plDirection = App.Placement()

                # section direction
                yL = selectedEdge.CenterOfMass
                uv = selectedEdge.Surface.parameter(yL)
                nv = selectedEdge.normalAt(uv[0], uv[1])
                direction = yL.sub(nv + yL)
                r = App.Rotation(App.Vector(0, 0, 0), direction)
                plDirection.Rotation.Q = r.Q
                #print(r.Q)
                plDirection.Base = yL
                plr = plDirection
                #print("surface : ", sel[0].Name, " ",SubElementName, "  ", direction)
                # section direction

                # section axis
                if createAxis != 0:
                    # section axis
                    points = [
                        App.Vector(0.0, 0.0, 0.0),
                        App.Vector(0.0, 0.0, ValueLength)
                    ]
                    centerX = _draft.makeWire(points,
                                              closed=False,
                                              face=False,
                                              support=None)
                    centerX.Placement = plr
                    centerX.Label = "Axis_" + SubElementName
                    # section axis

                #### section scale ####
                if createLoft != 0:
                    #### section scale ####
                    _part.show(selectedEdge.copy())
                    firstFace = App.ActiveDocument.ActiveObject
                    objClone = _draft.scale(
                        firstFace,
                        App.Vector(ValueScaleX, ValueScaleY, ValueScaleZ),
                        center=App.Vector(plDirection.Base),
                        copy=True)  # False

                    # section placement face in length and direction
                    newLocation = (App.Vector(direction).scale(
                        ValueLength, ValueLength, ValueLength))
                    if (direction.x != 0 and abs(direction.x) == direction.x):
                        newLocation.x = newLocation.x + selectedEdge.Placement.Base.x * direction.x
                    elif (direction.x != 0
                          and abs(direction.x) != direction.x):
                        newLocation.x = newLocation.x - selectedEdge.Placement.Base.x * direction.x
                    else:
                        newLocation.x = selectedEdge.Placement.Base.x
                    if (direction.y != 0
                            and abs(direction.y) == direction.y):  #positive >0
                        newLocation.y = newLocation.y + selectedEdge.Placement.Base.y * direction.y
                    elif (direction.y != 0
                          and abs(direction.x) != direction.y):  #negative <0
                        newLocation.y = newLocation.y - selectedEdge.Placement.Base.y * direction.y
                    else:
                        newLocation.y = selectedEdge.Placement.Base.y
                    if (direction.z != 0 and abs(direction.z) == direction.z):
                        newLocation.z = newLocation.z + selectedEdge.Placement.Base.z * direction.z
                    elif (direction.z != 0
                          and abs(direction.z) != direction.z):  #negative <0:
                        newLocation.z = newLocation.z - selectedEdge.Placement.Base.z * direction.z
                    else:
                        newLocation.z = selectedEdge.Placement.Base.z
                    objClone.Placement.Base = newLocation

                    # section loft
                    newObj = App.ActiveDocument.addObject('Part::Loft', 'Loft')
                    App.ActiveDocument.ActiveObject.Sections = [
                        App.ActiveDocument.getObject(firstFace.Name),
                        App.ActiveDocument.getObject(objClone.Name),
                    ]
                    App.ActiveDocument.ActiveObject.Solid = True
                    newObj = App.ActiveDocument.ActiveObject
                    App.ActiveDocument.recompute()

                    # copy
                    App.ActiveDocument.addObject('Part::Feature', newObj.Name +
                                                 'N').Shape = _part.getShape(
                                                     newObj,
                                                     '',
                                                     needSubElement=False,
                                                     refine=True)
                    App.ActiveDocument.recompute()

                    # Remove Old objects. I don't like to keep so many objects without any necessity.

                    for obj in newObj.Sections:
                        App.ActiveDocument.removeObject(obj.Name)
                    App.ActiveDocument.removeObject(newObj.Name)
                    App.ActiveDocument.commitTransaction()
                    App.ActiveDocument.recompute()
                    # section hidden faces work
            self.window.hide()
        except Exception as err:
            App.Console.PrintError("'Design456_loftOnDirection' Failed. "
                                   "{err}\n".format(err=str(err)))
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)
Exemple #22
0
    def Activated(self):
        try: 
            App.ActiveDocument.openTransaction(translate("Design456","LoftBetweenFaces"))
            selectedObj     = Gui.Selection.getSelectionEx()
            sel = selObjects = Gui.Selection.getSelection()
            Both3DObject=[False,False]
            try:
                subElementName = Gui.Selection.getSelectionEx()[0].SubElementNames[0] # for color first face selected
            except: 
                subElementName = Gui.Selection.getSelectionEx()[0].SubObjects[0]
                
            if (len(selectedObj) != 2):
                # Two object must be selected
                if (len(selectedObj[0].SubObjects)!=2):
                    errMessage = "Select two Faces of to use the Tool"
                    faced.errorDialog(errMessage)
                    return
            
            newObj1=newObj2=None
            if faced.isFaceOf3DObj(selectedObj[0]) is True:
                Both3DObject[0]=True
                try:
                    colorFace = App.ActiveDocument.getObject(sel[0].Name).ViewObject.DiffuseColor[int(SubElementName[4:])-1] # color face selected
                except Exception:
                    colorFace = App.ActiveDocument.getObject(sel[0].Name).ViewObject.DiffuseColor[0] # color face selected [0] 

                ### Begin command Part_ElementCopy First selection
                newFace1 = _part.getShape(App.ActiveDocument.getObject(sel[0].Name),selectedObj[0].SubElementNames[0],needSubElement=True,refine=False).copy()
                newObj1= App.ActiveDocument.addObject('Part::Feature','Face1')
                newObj1.Shape = newFace1
                App.ActiveDocument.recompute()
            else:
                newObj1=selectedObj[0].Object
            ####

            if faced.isFaceOf3DObj(selectedObj[0]) is True:
                Both3DObject[1]=True
                try:# independent object 
                    newFace2 = _part.getShape(App.ActiveDocument.getObject(sel[1].Name),selectedObj[1].SubElementNames[0],needSubElement=True,refine=False).copy()
                except Exception:
                    # same object other face  TODO: This will fail if you have a sphere shape or a ball Mariwan 2021-03-18
                    newFace2 = _part.getShape(App.ActiveDocument.getObject(sel[0].Name),selectedObj[0].SubElementNames[1],needSubElement=True,refine=False).copy()
                newObj2=App.ActiveDocument.addObject('Part::Feature','Face2')
                newObj2.Shape = newFace2
                App.ActiveDocument.recompute()
            else:
                newObj2=selectedObj[1].Object
            ### Part_Loft
            attached = App.ActiveDocument.addObject('Part::Loft','Attached')
            attached.Sections = [newObj1,newObj2 ]
            attached.Solid=True
            attached.Ruled=False
            attached.Closed=False
            ### End command Part_Loft
            App.ActiveDocument.recompute()

            ###Part_Fuse
            if (Both3DObject[0] ==True and Both3DObject[1]==True ):
                fusion = App.ActiveDocument.addObject("Part::MultiFuse","multiFusion")
                allObjects= []
                for o in selectedObj:
                    allObjects.append(o.Object)
                allObjects.append(attached)
                fusion.Shapes = allObjects
                App.ActiveDocument.recompute()
    
                #simplify object
                fusion.Shape.copy()
                newObj2.Shape = newFace2
                App.ActiveDocument.recompute()
    
                shp = fusion.Shape.copy()
                resultObj= App.ActiveDocument.addObject('Part::Feature','JoinedObjects')
                resultObj.Shape=shp
                App.ActiveDocument.recompute()
                
                ##### remove Objects 
                for obj in selectedObj:
                    App.ActiveDocument.removeObject(obj.Object.Name)
                App.ActiveDocument.removeObject(attached.Name)
                App.ActiveDocument.removeObject(fusion.Name)
                App.ActiveDocument.removeObject(newObj1.Name)
                App.ActiveDocument.removeObject(newObj2.Name)
            else:
                Gui.ActiveDocument.getObject(newObj1.Name).Visibility == False
                Gui.ActiveDocument.getObject(newObj2.Name).Visibility == False
                
                shp = attached.Shape.copy()
                resultObj= App.ActiveDocument.addObject('Part::Feature','JoinedObjects')
                resultObj.Shape=shp
                App.ActiveDocument.recompute()
                App.ActiveDocument.removeObject(attached.Name)
                App.ActiveDocument.removeObject(newObj1.Name)
                App.ActiveDocument.removeObject(newObj2.Name)
            App.ActiveDocument.recompute()
            App.ActiveDocument.commitTransaction() #undo reg.

        except Exception as err:
            App.Console.PrintError("'LoftBetweenFaces' Failed. "
                                   "{err}\n".format(err=str(err)))
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)
Exemple #23
0
    def Activated(self):
        try:
            sel = Gui.Selection.getSelection()
            if (len(sel) != 2):
                # Two object must be selected
                errMessage = "Select two objects to use the Tool"
                faced.errorDialog(errMessage)
                return
            reply = self.askQuestion()
            App.ActiveDocument.openTransaction(translate("Design456","LoftBetweenFaces"))
            Gui.ActiveDocument.getObject(sel[0].Name).Visibility=False
            Gui.ActiveDocument.getObject(sel[1].Name).Visibility=False

            #### Config Begin ####

            switchRemoveConstructionObject = self.askQuestion()    # if 0 (NO) not removed creation objects 1= (YES) remove objects
            colorCommon = (0.9373, 0.1608, 0.1608)
            colorCut1   = (0.4471, 0.6235, 0.8118)
            colorCut2   = (0.0235, 0.6902, 0.6902)
            colorFuse   = (1.0000, 0.6667, 0.0000)
            #### Config End ####

            ##### Begin command _part_Common
            #### create copy
            shapeCommon = _part.getShape(App.ActiveDocument.getObject(sel[0].Name),'',needSubElement=False,refine=False)
            App.ActiveDocument.addObject('Part::Feature','Common1').Shape = shapeCommon
            newObjectCut_A1 = App.ActiveDocument.ActiveObject
            shapeCommon = _part.getShape(App.ActiveDocument.getObject(sel[1].Name),'',needSubElement=False,refine=False)
            App.ActiveDocument.addObject('Part::Feature','Common2').Shape = shapeCommon
            newObjectCut_A2 = App.ActiveDocument.ActiveObject
            ####
            commonObject     = App.ActiveDocument.addObject("Part::MultiCommon","Common")
            commonObjectMake = App.ActiveDocument.getObject(commonObject.Name).Shapes = [App.ActiveDocument.getObject(newObjectCut_A1.Name), App.ActiveDocument.getObject(newObjectCut_A2.Name),]
            shapeCommonMake  = App.ActiveDocument.ActiveObject
            App.ActiveDocument.recompute()
            Gui.ActiveDocument.activeObject().ShapeColor = colorCommon
            ####
            shapeCommon = _part.getShape(App.ActiveDocument.getObject(shapeCommonMake.Name),'',needSubElement=False,refine=False)
            App.ActiveDocument.addObject('Part::Feature','shapeCommon').Shape = shapeCommon
            Gui.ActiveDocument.activeObject().ShapeColor = colorCommon
            if switchRemoveConstructionObject == 1:
                App.ActiveDocument.removeObject(shapeCommonMake.Name)
                App.ActiveDocument.removeObject(newObjectCut_A1.Name)
                App.ActiveDocument.removeObject(newObjectCut_A2.Name)
            #### End command Part_Common

            #### Begin command Part_Cut First
            #### create copy
            shapeCut1 = _part.getShape(App.ActiveDocument.getObject(sel[0].Name),'',needSubElement=False,refine=False)
            App.ActiveDocument.addObject('Part::Feature','Cut01').Shape = shapeCut1
            newObjectCut_A1 = App.ActiveDocument.ActiveObject
            shapeCut1 = _part.getShape(App.ActiveDocument.getObject(sel[1].Name),'',needSubElement=False,refine=False)
            App.ActiveDocument.addObject('Part::Feature','Cut02').Shape = shapeCut1
            newObjectCut_A2 = App.ActiveDocument.ActiveObject
            ####
            App.ActiveDocument.addObject("Part::Cut","Cut_01")
            App.ActiveDocument.Cut_01.Base = App.ActiveDocument.getObject(newObjectCut_A1.Name)
            App.ActiveDocument.Cut_01.Tool = App.ActiveDocument.getObject(newObjectCut_A2.Name)
            shapeCutMake  = App.ActiveDocument.ActiveObject
            App.ActiveDocument.recompute()
            Gui.ActiveDocument.activeObject().ShapeColor = colorCut1
            ####
            shapeCut01 = _part.getShape(App.ActiveDocument.getObject(shapeCutMake.Name),'',needSubElement=False,refine=False)
            App.ActiveDocument.addObject('Part::Feature','shapeCut01').Shape = shapeCut01
            Gui.ActiveDocument.activeObject().ShapeColor = colorCut1
            if switchRemoveConstructionObject == 1:
                App.ActiveDocument.removeObject(shapeCutMake.Name)
                App.ActiveDocument.removeObject(newObjectCut_A1.Name)
                App.ActiveDocument.removeObject(newObjectCut_A2.Name)
            #### End command Part_Cut First

            #### Begin command Part_Cut Second
            #### create copy
            shapeCut2 = _part.getShape(App.ActiveDocument.getObject(sel[1].Name),'',needSubElement=False,refine=False)
            App.ActiveDocument.addObject('Part::Feature','Cut01').Shape = shapeCut2
            newObjectCut_A1 = App.ActiveDocument.ActiveObject
            shapeCut2 = _part.getShape(App.ActiveDocument.getObject(sel[0].Name),'',needSubElement=False,refine=False)
            App.ActiveDocument.addObject('Part::Feature','Cut02').Shape = shapeCut2
            newObjectCut_A2 = App.ActiveDocument.ActiveObject
            ####
            App.ActiveDocument.addObject("Part::Cut","Cut_02")
            App.ActiveDocument.Cut_02.Base = App.ActiveDocument.getObject(newObjectCut_A1.Name)
            App.ActiveDocument.Cut_02.Tool = App.ActiveDocument.getObject(newObjectCut_A2.Name)
            shapeCutMake  = App.ActiveDocument.ActiveObject
            App.ActiveDocument.recompute()
            Gui.ActiveDocument.activeObject().ShapeColor = colorCut2
            ####
            shapeCut02 = _part.getShape(App.ActiveDocument.getObject(shapeCutMake.Name),'',needSubElement=False,refine=False)
            App.ActiveDocument.addObject('Part::Feature','shapeCut02').Shape = shapeCut02
            Gui.ActiveDocument.activeObject().ShapeColor = colorCut2
            if switchRemoveConstructionObject == 1:
                App.ActiveDocument.removeObject(shapeCutMake.Name)
                App.ActiveDocument.removeObject(newObjectCut_A1.Name)
                App.ActiveDocument.removeObject(newObjectCut_A2.Name)
            #### End command Part_Cut Second

            #### Begin command Part_Fuse
            #### create copy
            shapeFuse1 = _part.getShape(App.ActiveDocument.getObject(sel[1].Name),'',needSubElement=False,refine=False)
            App.ActiveDocument.addObject('Part::Feature','Fuse01').Shape = shapeFuse1
            newObjectFuse1 = App.ActiveDocument.ActiveObject
            shapeFuse2 = _part.getShape(App.ActiveDocument.getObject(sel[0].Name),'',needSubElement=False,refine=False)
            App.ActiveDocument.addObject('Part::Feature','Fuse02').Shape = shapeFuse2
            newObjectFuse2 = App.ActiveDocument.ActiveObject
            ####
            App.ActiveDocument.addObject("Part::MultiFuse","Fusion")
            App.ActiveDocument.Fusion.Shapes = [App.ActiveDocument.getObject(newObjectFuse1.Name),App.ActiveDocument.getObject(newObjectFuse2.Name),]
            shapeCutFusion  = App.ActiveDocument.ActiveObject
            App.ActiveDocument.recompute()
            Gui.ActiveDocument.activeObject().ShapeColor = colorFuse
            ####
            shapeFusion = _part.getShape(App.ActiveDocument.getObject(shapeCutFusion.Name),'',needSubElement=False,refine=False)
            App.ActiveDocument.addObject('Part::Feature','shapeFusion').Shape = shapeFusion
            Gui.ActiveDocument.activeObject().ShapeColor = colorFuse
            if switchRemoveConstructionObject == 1:
                App.ActiveDocument.removeObject(shapeCutFusion.Name)
                App.ActiveDocument.removeObject(newObjectFuse1.Name)
                App.ActiveDocument.removeObject(newObjectFuse2.Name)
            #### End command Part_Fuse
            App.ActiveDocument.commitTransaction() #undo reg.
        except Exception as err:
            App.Console.PrintError("'Design456_unifySplitFuse2' Failed. "
                                   "{err}\n".format(err=str(err)))
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)
Exemple #24
0
    def Activated(self):
        try:
            # Save object name that will be divided.
            selection = Gui.Selection.getSelectionEx()
            if (len(selection) < 1):
                # An object must be selected
                errMessage = "Select an object to use Split Tool"
                faced.errorDialog(errMessage)
                return
            App.ActiveDocument.openTransaction(
                translate("Design456", "Split Object"))
            shape = selection[0].Object.Shape
            bb = shape.BoundBox
            length = max(bb.XLength, bb.YLength, bb.ZLength)

            nameOfselectedObject = selection[0].ObjectName
            totalName = nameOfselectedObject + '_cs'
            """ slow function . . you need to use wait before getting 
                the answer as the execution is continuing down """
            Gui.runCommand('Part_CrossSections', 0)
            gcompund = App.ActiveDocument.addObject("Part::Compound",
                                                    "Compound")

            App.ActiveDocument.recompute()

            # get object name
            # We need this delay to let user choose the split form. And
            getExtrude_cs = None  # Dummy variable used to wait for the Extrude_cs be made
            while (getExtrude_cs is None):
                getExtrude_cs = App.ActiveDocument.getObject(totalName)
                _sleep(.1)
                Gui.updateGui()
            # Begin command Part_Compound
            gcompund.Links = [
                getExtrude_cs,
            ]

            # Begin command Part_BooleanFragments
            j = SPLIT.makeBooleanFragments(name='BooleanFragments')
            j.Objects = [
                gcompund,
                App.ActiveDocument.getObject(nameOfselectedObject)
            ]
            j.Mode = 'Standard'
            j.Proxy.execute(j)
            j.purgeTouched()
            App.ActiveDocument.recompute()
            if j.isValid() is False:
                App.ActiveDocument.removeObject(j.Name)
                # Shape != OK
                errMessage = "Failed to fillet the objects"
                faced.errorDialog(errMessage)
            else:
                # Make a simple copy
                newShape = Part.getShape(j,
                                         '',
                                         needSubElement=False,
                                         refine=False)
                NewJ = App.ActiveDocument.addObject(
                    'Part::Feature', 'SplitObject').Shape = newShape
                # Remove Old objects
                for obj in j.Objects:
                    App.ActiveDocument.removeObject(obj.Name)
                App.ActiveDocument.removeObject(totalName)
                App.ActiveDocument.removeObject(j.Name)
            App.ActiveDocument.commitTransaction()  #undo reg.
            App.ActiveDocument.recompute()
        except Exception as err:
            App.Console.PrintError("'SplitObject' Failed. "
                                   "{err}\n".format(err=str(err)))
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)
    def Activated(self):
        try:

            s = Gui.Selection.getSelectionEx()
            if (len(s) < 1 or len(s) > 2):
                # Two object must be selected
                errMessage = "Select two edges or two wire to make a face or "
                faced.errorDialog(errMessage)
                return
            elementsName = None
            subObj = None
            obj1 = None
            obj2 = None
            if len(s) == 1:
                obj1shp = s[0].SubObjects[0].copy()
                obj1 = App.ActiveDocument.addObject('Part::Feature', "E1")
                obj1.Shape = obj1shp
                obj2shp = s[0].SubObjects[1].copy()
                obj2 = App.ActiveDocument.addObject('Part::Feature', "E2")
                obj2.Shape = obj2shp
                App.ActiveDocument.recompute()
                elementsName = [obj1.Name, obj2.Name]
                subObj = [obj1, obj2]
            elif len(s) == 2:
                obj1shp = s[0].SubObjects[0].copy()
                obj1 = App.ActiveDocument.addObject('Part::Feature', "E1")
                obj1.Shape = obj1shp
                obj2shp = s[1].SubObjects[0].copy()
                obj2 = App.ActiveDocument.addObject('Part::Feature', "E2")
                obj2.Shape = obj2shp
                elementsName = [obj1.Name, obj2.Name]
                subObj = [obj1, obj2]
            for ss in s:
                word = ss.FullName
                if (word.find('Vertex') != -1):
                    # Two lines or curves or wires must be selected
                    errMessage = "Select two edges or two wires not Vertex"
                    faced.errorDialog(errMessage)
                    return
            App.ActiveDocument.openTransaction(
                translate("Design456", "Surface"))

            newObj = App.ActiveDocument.addObject('Part::RuledSurface',
                                                  'tempSurface')

            newObj.Curve1 = subObj[0]
            newObj.Curve2 = subObj[1]
            App.ActiveDocument.recompute()

            # Make a simple copy of the object
            newShape = _part.getShape(newObj,
                                      '',
                                      needSubElement=False,
                                      refine=True)
            tempNewObj = App.ActiveDocument.addObject('Part::Feature',
                                                      'Surface')
            tempNewObj.Shape = newShape
            App.ActiveDocument.ActiveObject.Label = 'Surface'
            App.ActiveDocument.recompute()
            if tempNewObj.isValid() is False:
                App.ActiveDocument.removeObject(tempNewObj.Name)
                # Shape != OK
                errMessage = "Failed to create the face"
                faced.errorDialog(errMessage)
            else:
                App.ActiveDocument.removeObject(newObj.Name)
                App.ActiveDocument.commitTransaction()  # undo reg.de here
                App.ActiveDocument.recompute()
                if (obj1 is not None and obj2 is not None):
                    App.ActiveDocument.removeObject(obj1.Name)
                    App.ActiveDocument.removeObject(obj2.Name)

        except Exception as err:
            App.Console.PrintError("'Part Surface' Failed. "
                                   "{err}\n".format(err=str(err)))
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)
Exemple #26
0
    def Activated(self):
        """[ Executes when the tool is used   ]
        """
        import ThreeDWidgets.fr_coinwindow as win
        try:

            print("Smart ExtrudeRotate")
            self.selected = Gui.Selection.getSelectionEx()
            if len(self.selected) == 0:
                # An object must be selected
                errMessage = "Select an object, one face to Extrude"
                faced.errorDialog(errMessage)
                return
            self.selectedObj = self.selected[0]
            faced.EnableAllToolbar(False)
            self.faceDir = faced.getDirectionAxis(
                self.selected)  # face direction

            # Undo
            App.ActiveDocument.openTransaction(
                translate("Design456", "SmartExtrudeRotate"))
            self.ExtractedFaces.clear()
            if self.isFaceOf3DObj(
            ):  # We must know if the selection is a 2D face or a face from a 3D object
                # We have a 3D Object. Extract a face and start to Extrude
                self.extractFaces()
            else:
                # We have a 2D Face - Extract it directly
                sh = self.selectedObj.Object.Shape.copy()
                o = App.ActiveDocument.addObject("Part::Feature",
                                                 "MovableFace")
                o.Shape = sh
                self.ExtractedFaces.append(self.selectedObj.Object)
                self.ExtractedFaces.append(App.ActiveDocument.getObject(
                    o.Name))
            facingdir = self.faceDir.upper()
            facingdir = facingdir[1:]
            print(facingdir, "facingdir")
            # Decide how the Degree Wheel be drawn
            self.setupRotation = self.calculateNewVector()
            if self.faceDir == "+z" or self.faceDir == "-z":
                self.wheelObj = Fr_DegreeWheel_Widget(
                    [self.FirstLocation,
                     App.Vector(0, 0, 0)],
                    str(round(self.w_rotation[3], 2)) + "°", 1,
                    FR_COLOR.FR_RED, [0, 0, 0, 0], self.setupRotation,
                    [2.0, 2.0, 2.0], 2, facingdir)
            else:
                self.wheelObj = Fr_DegreeWheel_Widget(
                    [self.FirstLocation,
                     App.Vector(0, 0, 0)],
                    str(round(self.w_rotation[3], 2)) + "°", 1,
                    FR_COLOR.FR_RED, [0, 0, 0, 0], self.setupRotation,
                    [2.0, 2.0, 2.0], 1, facingdir)

            # Define the callbacks. We have many callbacks here.
            # TODO: FIXME:

            # Different callbacks for each action.
            self.wheelObj.w_wheel_cb_ = callback_Rotate
            self.wheelObj.w_xAxis_cb_ = callback_moveX
            self.wheelObj.w_yAxis_cb_ = callback_moveY
            self.wheelObj.w_45Axis_cb_ = callback_move45
            self.wheelObj.w_135Axis_cb_ = callback_move135

            self.wheelObj.w_callback_ = callback_release
            self.wheelObj.w_userData.callerObject = self
            self.newObject = App.ActiveDocument.addObject(
                'Part::Loft', 'ExtendFace')
            self.newObject.Sections = self.ExtractedFaces
            self.newObject.Solid = True
            self.newObject.Ruled = False  # TODO: SHOULD THIS BE RULED?
            self.newObject.Closed = False  # TODO: SHOULD THIS BE CLOSED?
            self.ExtractedFaces[0].Visibility = False
            self.ExtractedFaces[1].Visibility = False
            if self._mywin is None:
                self._mywin = win.Fr_CoinWindow()

            self._mywin.addWidget(self.wheelObj)
            mw = self.getMainWindow()
            self._mywin.show()

            # TODO: FIXME:
            # loft will be used . make some experementations.
            # But when should we use sweep???? don't know now

            App.ActiveDocument.recompute()

        except Exception as err:
            faced.EnableAllToolbar(True)
            App.Console.PrintError(
                "'Design456_ExtrudeRotate' ExtractFace-Failed. "
                "{err}\n".format(err=str(err)))
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)
Exemple #27
0
    def Activated(self):
        """[Executes when the tool is used]
        """
        import ThreeDWidgets.fr_coinwindow as win
        try:
            print("Smart Extrusion")
            sel = Gui.Selection.getSelectionEx()
            if len(sel) == 0:
                # An object must be selected
                errMessage = "Select a face to Extrude"
                faced.errorDialog(errMessage)
                return
            self.selectedObj = sel[0]
            # Whole object is selected TODO: FIXME: Check if this works always.
            if len(self.selectedObj.SubObjects) == 0:
                errMessage = "Select a face to Extrude"
                faced.errorDialog(errMessage)
                return
            faced.EnableAllToolbar(False)
            # Undo
            App.ActiveDocument.openTransaction(
                translate("Design456", "SmartExtrude"))
            self.WasFaceFrom3DObject = self.isFaceOf3DObj()
            if self.WasFaceFrom3DObject is True:  # We must know if the selection is a 2D face or a face from a 3D object
                # We have a 3D Object. Extract a face and start to Extrude
                self.targetFace = self.extractFace()
            else:
                # We have a 2D Face - Extract it directly
                self.targetFace = self.selectedObj.Object

            rotation = self.getArrowPosition()
            self.smartInd = Fr_Arrow_Widget(self._vector, [
                "  Length 0.0",
            ], 1, FR_COLOR.FR_RED, FR_COLOR.FR_WHITE, rotation,
                                            [1.2, 1.2, 1.2], 3, 0.0)

            self.smartInd.w_callback_ = callback_release
            self.smartInd.w_move_callback_ = callback_move
            self.smartInd.w_userData.callerObject = self
            if self._mywin is None:
                self._mywin = win.Fr_CoinWindow()

            self._mywin.addWidget(self.smartInd)
            mw = self.getMainWindow()
            self._mywin.show()

            self.newObject = App.ActiveDocument.addObject(
                'Part::Extrusion', 'Extrude')
            self.newObject.Base = self.targetFace
            self.newObject.DirMode = "Normal"  # Don't use Custom as it causes a PROBLEM!
            # Above statement is not always correct. Some faces require 'custom'
            self.newObject.DirLink = None
            self.newObject.LengthFwd = self.extrudeLength  # Must be negative
            self.newObject.LengthRev = 0.0
            self.newObject.Solid = True
            self.newObject.Reversed = False
            self.newObject.Symmetric = False
            self.newObject.TaperAngle = 0.0
            self.newObject.TaperAngleRev = 0.0
            self.newObject.Dir = Gui.ActiveDocument.getObject(
                self.targetFace.Name).Object.Shape.Faces[0].normalAt(0, 0)
            if (self.newObject.Dir.x != 1 or self.newObject.Dir.y != 1
                    or self.newObject.Dir.z != 1):
                self.newObject.DirMode = "Custom"

            App.ActiveDocument.recompute()

        except Exception as err:
            faced.EnableAllToolbar(True)
            App.Console.PrintError("'Design456_Extrude' Activated-Failed. "
                                   "{err}\n".format(err=str(err)))
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)
Exemple #28
0
    def Activated(self):
        """[ Executes when the tool is used   ]
        """
        import ThreeDWidgets.fr_coinwindow as win
        self.coinFaces = coin.SoSeparator()
        self.w_rotation = [0.0, 0.0, 0.0]  # disc rotation
        self.setupRotation = [0, 0, 0, 0]  # Whole widget rotation
        self._Vector = App.Vector(0.0, 0.0, 0.0)  # disc POSITION
        self.counter = 0
        self.run_Once = False
        self.tweakLength = 0
        self.oldTweakLength = 0
        self.newFaces = []
        self.savedVertexes = [[]]
        self.tweakLength = 0

        try:
            self.view = Gui.ActiveDocument.ActiveView
            self.sg = self.view.getSceneGraph()
            sel = Gui.Selection.getSelectionEx()

            if len(sel) > 2:
                errMessage = "Please select only one face and try again"
                faced.errorDialog(errMessage)
                return
            # Register undo
            App.ActiveDocument.openTransaction(
                translate("Design456", "ExtendFace"))
            self.selectedObj = sel[0].Object
            self.selectedObj.Visibility = False
            if (hasattr(sel[0], "SubObjects")):
                self.selectedFace = sel[0].SubObjects[0]
            else:
                raise Exception("Not implemented")

            if self.selectedFace.ShapeType != 'Face':
                errMessage = "Please select only one face and try again, was: " + \
                    str(self.selectedFace.ShapeType)
                faced.errorDialog(errMessage)
                return

            # Recreate the object in separated shapes.
            self.saveVertexes()

            if (hasattr(self.selectedFace, "Vertexes")):
                #self.oldFaceVertexes = self.selectedFace.OuterWire.OrderedVertexes
                self.oldFaceVertexes = self.selectedFace.Vertexes
            if not hasattr(self.selectedFace, 'Faces'):
                raise Exception("Please select only one face and try again")
            # TODO: FIXME: WHAT SHOULD WE DO WHEN IT IS A CURVED FACE???
            # if not(type(self.selectedFace.Curve) == _part.Line or
            #       type(self.selectedFace.Curve) == _part.BezierCurve):
            #    msg = "Curve Faces are not supported yet"
            #    faced.errorDialog(msg)
            #    self.hide()

            self.setupRotation = self.calculateNewVector()

            self.ExtractFace()
            self.newFaceVertexes = self.newFace.Shape.Vertexes
            App.ActiveDocument.removeObject(self.selectedObj.Name)

            # Undo
            App.ActiveDocument.openTransaction(
                translate("Design456", "ExtendFace"))

            # Decide how the Degree pad be drawn
            self.discObj = Fr_ThreeArrows_Widget(
                [self.FirstLocation, App.Vector(0, 0, 0)],  #
                # label
                [
                    (str(round(self.w_rotation[0], 2)) + "°" +
                     str(round(self.w_rotation[1], 2)) + "°" +
                     str(round(self.w_rotation[2], 2)) + "°"),
                ],
                FR_COLOR.FR_WHITE,  # lblcolor
                [FR_COLOR.FR_RED, FR_COLOR.FR_GREEN, FR_COLOR.FR_BLUE
                 ],  # arrows color
                # rotation of the disc main
                [0, 0, 0, 0],
                self.setupRotation,  # setup rotation
                [30.0, 30.0, 30.0],  # scale
                1,  # type
                0,  # opacity
                10)  # distance between them
            self.discObj.enableDiscs()

            # Different callbacks for each action.
            self.discObj.w_xAxis_cb_ = self.MouseDragging_cb
            self.discObj.w_yAxis_cb_ = self.MouseDragging_cb
            self.discObj.w_zAxis_cb_ = self.MouseDragging_cb

            self.discObj.w_discXAxis_cb_ = self.RotatingFace_cb
            self.discObj.w_discYAxis_cb_ = self.RotatingFace_cb
            self.discObj.w_discZAxis_cb_ = self.RotatingFace_cb

            self.discObj.w_callback_ = self.callback_release
            self.discObj.w_userData.callerObject = self

            self.COIN_recreateObject()

            if self._mywin is None:
                self._mywin = win.Fr_CoinWindow()

            self._mywin.addWidget(self.discObj)
            mw = self.getMainWindow()
            self._mywin.show()

            App.ActiveDocument.recompute()

        except Exception as err:

            App.Console.PrintError("'Activated' Failed. "
                                   "{err}\n".format(err=str(err)))
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)
def smartlbl_callback(smartLine, obj, parentlink):
    """
        callback when label is double clicked
    """
    # clone the object
    p1 = smartLine.w_vector[0]
    p2 = smartLine.w_vector[1]
    deltaX = p2.x - p1.x
    deltaY = p2.y - p1.y
    deltaZ = p2.z - p1.z
    side = None
    if deltaX == 0 and deltaZ == 0:
        side = 'y'
    elif deltaY == 0.0 and deltaZ == 0.0:
        side = 'x'
    elif deltaY == 0.0 and deltaX == 0.0 and deltaZ != 0.0:
        side = 'z'
    newValue = 0
    # all lines has a 4 mm more size due to the way we calculate them. Remove that
    newValue = faced.GetInputValue().getDoubleValue()
    if newValue == 0 or newValue is None:
        # User canceled the value
        return -1

    if obj is None:
        # Only one object must be selected
        errMessage = "Select an object to scale"
        faced.errorDialog(errMessage)
        return

    cloneObj = Draft.clone(obj, forcedraft=True)
    scaleX = 1
    scaleY = 1
    scaleZ = 1

    if side == 'y':
        scaleY = newValue / (deltaY - SeperateLinesFromObject)
    elif side == 'x':
        scaleX = newValue / (deltaX - SeperateLinesFromObject)
    elif side == 'z':
        scaleZ = newValue / deltaZ
    else:
        print("error")
    try:
        App.ActiveDocument.openTransaction(translate("Design456",
                                                     "SmartScale"))
        cloneObj.Scale = App.Vector(scaleX, scaleY, scaleZ)

        obj.Visibility = False
        App.ActiveDocument.recompute()
        _name = obj.Label
        obj.Label = obj.Label + "old"
        __shape = Part.getShape(cloneObj,
                                '',
                                needSubElement=False,
                                refine=False)
        _simpleCopy = App.ActiveDocument.addObject('Part::Feature', _name)
        _simpleCopy.Shape = __shape
        App.ActiveDocument.recompute()
        App.ActiveDocument.removeObject(obj.Name)
        App.ActiveDocument.removeObject(cloneObj.Name)
        Gui.Selection.clearSelection()
        Gui.Selection.addSelection(_simpleCopy)
        _simpleCopy.Label = _name
        App.ActiveDocument.recompute()
        # All objects must get link to the new targeted object
        (_vectors,
         _lengths) = parentlink.returnVectorsFromBoundaryBox(_simpleCopy)
        for i in range(0, 3):
            parentlink.smartInd[i].set_target(_simpleCopy)
            parentlink.smartInd[i].w_vector = _vectors[i]
            parentlink.smartInd[i].changeLabelfloat(_lengths[i])
            parentlink.smartInd[i].redraw()  # Update the vertices here
        App.ActiveDocument.recompute()
        App.ActiveDocument.commitTransaction()  # undo reg.

    except Exception as err:
        App.Console.PrintError("'Design456_SmartScale' Failed. "
                               "{err}\n".format(err=str(err)))
        exc_type, exc_obj, exc_tb = sys.exc_info()
        fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
        print(exc_type, fname, exc_tb.tb_lineno)
Exemple #30
0
    def Activated(self):
        """[ Executes when the tool is used   ]
        """
        import ThreeDWidgets.fr_coinwindow as win
        self.coinFaces = coin.SoSeparator()
        self.w_rotation = [0.0, 0.0, 0.0]  #
        self.setupRotation = [0, 0, 0, 0]
        self.counter = 0
        self.run_Once = False
        self.tweakLength = 0
        self.oldTweakLength = 0
        self.isItRotation = False
        self.newFaces = []
        self.savedVertices = [[]]
        self.tweakLength = 0
        self.oldTweakLength = 0

        try:
            self.view = Gui.ActiveDocument.ActiveView
            self.sg = self.view.getSceneGraph()
            sel = Gui.Selection.getSelectionEx()

            if len(sel) > 2:
                errMessage = "Please select only one edge and try again"
                faced.errorDialog(errMessage)

            App.ActiveDocument.openTransaction(
                translate("Design456", "ExtendEdge"))

            self.MoveMentDirection = 'A'

            self.selectedObj = sel[0].Object
            self.selectedObj.Visibility = False
            if (hasattr(sel[0], "SubObjects")):
                self.selectedEdge = sel[0].SubObjects[0]
            else:
                raise Exception("Not implemented")

            if (not hasattr(self.selectedEdge, "Curve")):
                errmsg = "Please select an edge "
                faced.errorDialog(errmsg)
                self.selectedObj.Visibility = True
                self.__del__()
                return

            # Register undo
            App.ActiveDocument.openTransaction(
                translate("Design456", "EdgeExtend"))

            # Recreate the object in separated shapes.
            self.saveVertices()

            if (hasattr(self.selectedEdge, "Vertexes")):
                self.oldEdgeVertexes = self.selectedEdge.Vertexes
            if not hasattr(self.selectedEdge, 'Edges'):
                raise Exception("Please select only one edge and try again")
            if not (type(self.selectedEdge.Curve) == _part.Line
                    or type(self.selectedEdge.Curve) == _part.BezierCurve):
                msg = "Curve edges are not supported yet"
                faced.errorDialog(msg)
                return

            self.setupRotation = self.calculateNewVector()

            self.ExtractTheEdge()
            self.newEdgeVertexes = self.newEdge.Shape.Vertexes
            App.ActiveDocument.removeObject(self.selectedObj.Name)

            # Undo
            App.ActiveDocument.openTransaction(
                translate("Design456", "ExtendEdge"))

            if self.oldEdgeVertexes[
                    0].Point.z < self.selectedObj.Shape.BoundBox.ZMin:
                self.FirstLocation.z = self.selectedObj.Shape.BoundBox.ZMin - self.awayFromObj

            # Decide how the Degree disc be drawn
            self.discObj = Fr_ThreeArrows_Widget(
                [self.FirstLocation, App.Vector(0, 0, 0)],  #
                # label
                (str(round(self.w_rotation[0], 2)) + "°" +
                 str(round(self.w_rotation[1], 2)) + "°" +
                 str(round(self.w_rotation[2], 2)) + "°"),
                FR_COLOR.FR_WHITE,  # lblcolor
                [FR_COLOR.FR_RED, FR_COLOR.FR_GREEN, FR_COLOR.FR_BLUE
                 ],  # arrows color
                # rotation
                [0.0, 0.0, 0.0, 0.0],
                self.setupRotation,  # setup rotation
                [15.0, 15.0, 15.0],  # scale
                0,  # type
                0,  # opacity
                10)  # distance between them

            # Different callbacks for each action.
            self.discObj.w_xAxis_cb_ = self.MouseMovement_cb
            self.discObj.w_yAxis_cb_ = self.MouseMovement_cb
            self.discObj.w_zAxis_cb_ = self.MouseMovement_cb

            self.discObj.w_discXAxis_cb_ = self.callback_Rotate
            self.discObj.w_discYAxis_cb_ = self.callback_Rotate
            self.discObj.w_discZAxis_cb_ = self.callback_Rotate

            self.discObj.w_callback_ = self.callback_release
            self.discObj.w_userData.callerObject = self

            self.COIN_recreateObject()

            if self._mywin is None:
                self._mywin = win.Fr_CoinWindow()

            self._mywin.addWidget(self.discObj)
            mw = self.getMainWindow()
            self._mywin.show()

            App.ActiveDocument.recompute()

        except Exception as err:

            App.Console.PrintError("'Activated' Failed. "
                                   "{err}\n".format(err=str(err)))
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)