def Activated(self):
     """Execute when the command is called."""
     name = translate("draft", "ShapeString")
     super(ShapeString, self).Activated(name)
     self.creator = gui_base_original.Creator
     if self.ui:
         self.ui.sourceCmd = self
         self.taskmode = utils.getParam("UiMode", 1)
         if self.taskmode:
             # This doesn't use the task panel defined in DraftGui
             # so it is deleted and a new task panel is installed
             try:
                 del self.task
             except AttributeError:
                 pass
             self.task = task_shapestring.ShapeStringTaskPanel()
             self.task.sourceCmd = self
             todo.ToDo.delay(Gui.Control.showDialog, self.task)
         else:
             self.dialog = None
             self.text = ''
             self.ui.sourceCmd = self
             self.ui.pointUi(name)
             self.active = True
             self.call = self.view.addEventCallback("SoEvent", self.action)
             self.ssBase = None
             self.ui.xValue.setFocus()
             self.ui.xValue.selectAll()
             _msg(translate("draft", "Pick ShapeString location point"))
             Gui.draftToolBar.show()
Example #2
0
    def finish(self, closed=False, cont=False):
        """Terminate the operation and close the polyline if asked.

        Parameters
        ----------
        closed: bool, optional
            Close the line if `True`.
        """
        self.removeTemporaryObject()
        if self.oldWP:
            App.DraftWorkingPlane.setFromParameters(self.oldWP)
            if hasattr(Gui, "Snapper"):
                Gui.Snapper.setGrid()
                Gui.Snapper.restack()
        self.oldWP = None

        if len(self.node) > 1:
            Gui.addModule("Draft")
            # The command to run is built as a series of text strings
            # to be committed through the `draftutils.todo.ToDo` class.
            if (len(self.node) == 2
                    and utils.getParam("UsePartPrimitives", False)):
                # Insert a Part::Primitive object
                p1 = self.node[0]
                p2 = self.node[-1]

                _cmd = 'FreeCAD.ActiveDocument.'
                _cmd += 'addObject("Part::Line", "Line")'
                _cmd_list = [
                    'line = ' + _cmd, 'line.X1 = ' + str(p1.x),
                    'line.Y1 = ' + str(p1.y), 'line.Z1 = ' + str(p1.z),
                    'line.X2 = ' + str(p2.x), 'line.Y2 = ' + str(p2.y),
                    'line.Z2 = ' + str(p2.z), 'Draft.autogroup(line)',
                    'FreeCAD.ActiveDocument.recompute()'
                ]
                self.commit(translate("draft", "Create Line"), _cmd_list)
            else:
                # Insert a Draft line
                rot, sup, pts, fil = self.getStrings()

                _base = DraftVecUtils.toString(self.node[0])
                _cmd = 'Draft.make_wire'
                _cmd += '('
                _cmd += 'points, '
                _cmd += 'placement=pl, '
                _cmd += 'closed=' + str(closed) + ', '
                _cmd += 'face=' + fil + ', '
                _cmd += 'support=' + sup
                _cmd += ')'
                _cmd_list = [
                    'pl = FreeCAD.Placement()', 'pl.Rotation.Q = ' + rot,
                    'pl.Base = ' + _base, 'points = ' + pts, 'line = ' + _cmd,
                    'Draft.autogroup(line)',
                    'FreeCAD.ActiveDocument.recompute()'
                ]
                self.commit(translate("draft", "Create Wire"), _cmd_list)
        super(Line, self).finish()
        if self.ui and self.ui.continueMode:
            self.Activated()
Example #3
0
 def createObject(self):
     """Create the actual object in the current document."""
     plane = App.DraftWorkingPlane
     p1 = self.node[0]
     p3 = self.node[-1]
     diagonal = p3.sub(p1)
     halfdiag = App.Vector(diagonal).multiply(0.5)
     center = p1.add(halfdiag)
     p2 = p1.add(DraftVecUtils.project(diagonal, plane.v))
     p4 = p1.add(DraftVecUtils.project(diagonal, plane.u))
     r1 = (p4.sub(p1).Length) / 2
     r2 = (p2.sub(p1).Length) / 2
     try:
         # The command to run is built as a series of text strings
         # to be committed through the `draftutils.todo.ToDo` class.
         rot, sup, pts, fil = self.getStrings()
         if r2 > r1:
             r1, r2 = r2, r1
             m = App.Matrix()
             m.rotateZ(math.pi / 2)
             rot1 = App.Rotation()
             rot1.Q = eval(rot)
             rot2 = App.Placement(m)
             rot2 = rot2.Rotation
             rot = str((rot1.multiply(rot2)).Q)
         if utils.getParam("UsePartPrimitives", False):
             # Insert a Part::Primitive object
             Gui.addModule("Part")
             _cmd = 'FreeCAD.ActiveDocument.'
             _cmd += 'addObject("Part::Ellipse", "Ellipse")'
             _cmd_list = [
                 'ellipse = ' + _cmd, 'ellipse.MajorRadius = ' + str(r1),
                 'ellipse.MinorRadius = ' + str(r2),
                 'pl = FreeCAD.Placement()', 'pl.Rotation.Q= ' + rot,
                 'pl.Base = ' + DraftVecUtils.toString(center),
                 'ellipse.Placement = pl', 'Draft.autogroup(ellipse)',
                 'FreeCAD.ActiveDocument.recompute()'
             ]
             self.commit(translate("draft", "Create Ellipse"), _cmd_list)
         else:
             # Insert a Draft ellipse
             Gui.addModule("Draft")
             _cmd = 'Draft.makeEllipse'
             _cmd += '('
             _cmd += str(r1) + ', ' + str(r2) + ', '
             _cmd += 'placement=pl, '
             _cmd += 'face=' + fil + ', '
             _cmd += 'support=' + sup
             _cmd += ')'
             _cmd_list = [
                 'pl = FreeCAD.Placement()', 'pl.Rotation.Q = ' + rot,
                 'pl.Base = ' + DraftVecUtils.toString(center),
                 'ellipse = ' + _cmd, 'Draft.autogroup(ellipse)',
                 'FreeCAD.ActiveDocument.recompute()'
             ]
             self.commit(translate("draft", "Create Ellipse"), _cmd_list)
     except Exception:
         _err("Draft: Error: Unable to create object.")
     self.finish(cont=True)
Example #4
0
 def createObject(self):
     """Create the final object in the current document."""
     plane = App.DraftWorkingPlane
     p1 = self.node[0]
     p3 = self.node[-1]
     diagonal = p3.sub(p1)
     p2 = p1.add(DraftVecUtils.project(diagonal, plane.v))
     p4 = p1.add(DraftVecUtils.project(diagonal, plane.u))
     length = p4.sub(p1).Length
     if abs(DraftVecUtils.angle(p4.sub(p1), plane.u, plane.axis)) > 1:
         length = -length
     height = p2.sub(p1).Length
     if abs(DraftVecUtils.angle(p2.sub(p1), plane.v, plane.axis)) > 1:
         height = -height
     try:
         # The command to run is built as a series of text strings
         # to be committed through the `draftutils.todo.ToDo` class.
         rot, sup, pts, fil = self.getStrings()
         base = p1
         if length < 0:
             length = -length
             base = base.add((p1.sub(p4)).negative())
         if height < 0:
             height = -height
             base = base.add((p1.sub(p2)).negative())
         Gui.addModule("Draft")
         if utils.getParam("UsePartPrimitives", False):
             # Insert a Part::Primitive object
             _cmd = 'FreeCAD.ActiveDocument.'
             _cmd += 'addObject("Part::Plane", "Plane")'
             _cmd_list = [
                 'plane = ' + _cmd, 'plane.Length = ' + str(length),
                 'plane.Width = ' + str(height), 'pl = FreeCAD.Placement()',
                 'pl.Rotation.Q=' + rot,
                 'pl.Base = ' + DraftVecUtils.toString(base),
                 'plane.Placement = pl', 'Draft.autogroup(plane)',
                 'FreeCAD.ActiveDocument.recompute()'
             ]
             self.commit(translate("draft", "Create Plane"), _cmd_list)
         else:
             _cmd = 'Draft.makeRectangle'
             _cmd += '('
             _cmd += 'length=' + str(length) + ', '
             _cmd += 'height=' + str(height) + ', '
             _cmd += 'placement=pl, '
             _cmd += 'face=' + fil + ', '
             _cmd += 'support=' + sup
             _cmd += ')'
             _cmd_list = [
                 'pl = FreeCAD.Placement()', 'pl.Rotation.Q = ' + rot,
                 'pl.Base = ' + DraftVecUtils.toString(base),
                 'rec = ' + _cmd, 'Draft.autogroup(rec)',
                 'FreeCAD.ActiveDocument.recompute()'
             ]
             self.commit(translate("draft", "Create Rectangle"), _cmd_list)
     except Exception:
         _err("Draft: error delaying commit")
     self.finish(cont=True)
Example #5
0
 def createDefaultPage(self):
     """Create a default Drawing Workbench page."""
     _t = App.getResourceDir() + 'Mod/Drawing/Templates/A3_Landscape.svg'
     template = utils.getParam("template", _t)
     page = self.doc.addObject('Drawing::FeaturePage', 'Page')
     page.ViewObject.HintOffsetX = 200
     page.ViewObject.HintOffsetY = 100
     page.ViewObject.HintScale = 2
     page.Template = template
     self.doc.recompute()
     return page
Example #6
0
    def finish(self, closed=False, cont=False):
        """Terminate the operation and close the curve if asked.

        Parameters
        ----------
        closed: bool, optional
            Close the line if `True`.
        """
        if self.ui:
            if hasattr(self, "bezcurvetrack"):
                self.bezcurvetrack.finalize()
        if not utils.getParam("UiMode", 1):
            Gui.Control.closeDialog()
        if self.obj:
            # remove temporary object, if any
            old = self.obj.Name
            todo.ToDo.delay(self.doc.removeObject, old)
        if closed is False:
            cleannd = (len(self.node) - 1) % self.degree
            if cleannd == 0:
                self.node = self.node[0:-3]
            if cleannd > 0:
                self.node = self.node[0:-cleannd]
        if len(self.node) > 1:
            try:
                # The command to run is built as a series of text strings
                # to be committed through the `draftutils.todo.ToDo` class.
                rot, sup, pts, fil = self.getStrings()
                Gui.addModule("Draft")
                _cmd = 'Draft.makeBezCurve'
                _cmd += '('
                _cmd += 'points, '
                _cmd += 'closed=' + str(closed) + ', '
                _cmd += 'support=' + sup + ', '
                _cmd += 'degree=' + str(self.degree)
                _cmd += ')'
                _cmd_list = ['points = ' + pts,
                             'bez = ' + _cmd,
                             'Draft.autogroup(bez)',
                             'FreeCAD.ActiveDocument.recompute()']
                self.commit(translate("draft", "Create BezCurve"),
                            _cmd_list)
            except Exception:
                _err("Draft: error delaying commit")

        # `Creator` is the grandfather class, the parent of `Line`;
        # we need to call it to perform final cleanup tasks.
        #
        # Calling it directly like this is a bit messy; maybe we need
        # another method that performs cleanup (superfinish)
        # that is not re-implemented by any of the child classes.
        gui_base_original.Creator.finish(self)
        if self.ui and self.ui.continueMode:
            self.Activated()
    def finish(self, closed=False, cont=False):
        """Terminate the operation and close the spline if asked.

        Parameters
        ----------
        closed: bool, optional
            Close the line if `True`.
        """
        # if self.ui:
        # self.linetrack.finalize()
        if not utils.getParam("UiMode", 1):
            Gui.Control.closeDialog()
        if self.obj:
            # Remove temporary object, if any
            old = self.obj.Name
            todo.ToDo.delay(self.doc.removeObject, old)
        if len(self.node) > 1:
            # The command to run is built as a series of text strings
            # to be committed through the `draftutils.todo.ToDo` class.
            try:
                # rot, sup, pts, fil = self.getStrings()

                cmd_list = [
                    'from FreeCAD import Vector',
                    'from safe.punch.beam import make_beam',
                    'from safe.punch.base_foundation import make_base_foundation',
                    'beams = []',
                ]

                for p1, p2 in zip(self.node[:-1], self.node[1:]):
                    cmd_list.append(f'beam = make_beam({p1}, {p2})')
                    cmd_list.append(f'beams.append(beam)')
                hide_beams = self.hide_beams_checkbox.isChecked()
                cmd_list.append(
                    f'make_base_foundation(beams, "{self.layer}", {self.bf_width}, {self.bf_height}, {self.bf_soil_modulus}, "{self.bf_align}", {self.bf_left_width}, {self.bf_right_width}, {hide_beams} )'
                )
                self.commit(translate("civil", "Create Base Foundation"),
                            cmd_list)
                FreeCAD.ParamGet(
                    "User parameter:BaseApp/Preferences/Mod/OSAFE").SetBool(
                        "base_foundation_hide_beams", hide_beams)
            except Exception:
                _err("Draft: error delaying commit")

        # `Creator` is the grandfather class, the parent of `Line`;
        # we need to call it to perform final cleanup tasks.
        #
        # Calling it directly like this is a bit messy; maybe we need
        # another method that performs cleanup (superfinish)
        # that is not re-implemented by any of the child classes.
        gui_base_original.Creator.finish(self)
        if self.ui and self.ui.continueMode:
            self.Activated()
Example #8
0
    def click(self, event_cb=None):
        """Execute as a callback when the pointer clicks on the 3D view.

        It should act as if the Enter key was pressed, or the OK button
        was pressed in the task panel.
        """
        if event_cb:
            event = event_cb.getEvent()
            if event.getState() != coin.SoMouseButtonEvent.DOWN:
                return
        if self.point:
            self.stack.append(self.point)
            if len(self.stack) == 1:
                self.view.removeEventCallbackPivy(
                    coin.SoMouseButtonEvent.getClassTypeId(),
                    self.callbackClick)
                self.view.removeEventCallbackPivy(
                    coin.SoLocation2Event.getClassTypeId(), self.callbackMove)
                # The command to run is built as a series of text strings
                # to be committed through the `draftutils.todo.ToDo` class.
                commitlist = []
                if utils.getParam("UsePartPrimitives", False):
                    # Insert a Part::Primitive object
                    _cmd = 'FreeCAD.ActiveDocument.'
                    _cmd += 'addObject("Part::Vertex", "Point")'
                    _cmd_list = [
                        'point = ' + _cmd,
                        'point.X = ' + str(self.stack[0][0]),
                        'point.Y = ' + str(self.stack[0][1]),
                        'point.Z = ' + str(self.stack[0][2]),
                        'Draft.autogroup(point)',
                        'FreeCAD.ActiveDocument.recompute()'
                    ]
                    commitlist.append((translate("draft",
                                                 "Create Point"), _cmd_list))
                else:
                    # Insert a Draft point
                    Gui.addModule("Draft")
                    _cmd = 'Draft.makePoint'
                    _cmd += '('
                    _cmd += str(self.stack[0][0]) + ', '
                    _cmd += str(self.stack[0][1]) + ', '
                    _cmd += str(self.stack[0][2])
                    _cmd += ')'
                    _cmd_list = [
                        'point = ' + _cmd, 'Draft.autogroup(point)',
                        'FreeCAD.ActiveDocument.recompute()'
                    ]
                    commitlist.append((translate("draft",
                                                 "Create Point"), _cmd_list))
                todo.ToDo.delayCommit(commitlist)
                Gui.Snapper.off()
            self.finish()
Example #9
0
 def Activated(self):
     """Execute when the command is called."""
     super(Rectangle, self).Activated(name="Rectangle")
     if self.ui:
         self.refpoint = None
         self.ui.pointUi(title=translate("draft", self.featureName), icon="Draft_Rectangle")
         self.ui.extUi()
         if utils.getParam("UsePartPrimitives", False):
             self.fillstate = self.ui.hasFill.isChecked()
             self.ui.hasFill.setChecked(True)
         self.call = self.view.addEventCallback("SoEvent", self.action)
         self.rect = trackers.rectangleTracker()
         _msg(translate("draft", "Pick first point"))
Example #10
0
 def Activated(self):
     """Execute when the command is called."""
     self.name = translate("draft", "Label")
     super().Activated(self.name, noplanesetup=True)
     self.ghost = None
     self.labeltype = utils.getParam("labeltype", "Custom")
     self.sel = Gui.Selection.getSelectionEx()
     if self.sel:
         self.sel = self.sel[0]
     self.ui.labelUi(self.name, callback=self.setmode)
     self.ui.xValue.setFocus()
     self.ui.xValue.selectAll()
     self.ghost = trackers.lineTracker()
     self.call = self.view.addEventCallback("SoEvent", self.action)
     _msg(translate("draft", "Pick target point"))
     self.ui.isCopy.hide()
Example #11
0
 def drawPolygon(self):
     """Draw the actual object."""
     rot, sup, pts, fil = self.getStrings()
     Gui.addModule("Draft")
     if utils.getParam("UsePartPrimitives", False):
         # Insert a Part::Primitive object
         Gui.addModule("Part")
         _cmd = 'FreeCAD.ActiveDocument.'
         _cmd += 'addObject("Part::RegularPolygon","RegularPolygon")'
         _cmd_list = ['pl = FreeCAD.Placement()',
                      'pl.Rotation.Q = ' + rot,
                      'pl.Base = ' + DraftVecUtils.toString(self.center),
                      'pol = ' + _cmd,
                      'pol.Polygon = ' + str(self.ui.numFaces.value()),
                      'pol.Circumradius = ' + str(self.rad),
                      'pol.Placement = pl',
                      'Draft.autogroup(pol)',
                      'FreeCAD.ActiveDocument.recompute()']
         self.commit(translate("draft", "Create Polygon (Part)"),
                     _cmd_list)
     else:
         # Insert a Draft polygon
         _cmd = 'Draft.make_polygon'
         _cmd += '('
         _cmd += str(self.ui.numFaces.value()) + ', '
         _cmd += 'radius=' + str(self.rad) + ', '
         _cmd += 'inscribed=True, '
         _cmd += 'placement=pl, '
         _cmd += 'face=' + fil + ', '
         _cmd += 'support=' + sup
         _cmd += ')'
         _cmd_list = ['pl = FreeCAD.Placement()',
                      'pl.Rotation.Q = ' + rot,
                      'pl.Base = ' + DraftVecUtils.toString(self.center),
                      'pol = ' + _cmd,
                      'Draft.autogroup(pol)',
                      'FreeCAD.ActiveDocument.recompute()']
         self.commit(translate("draft", "Create Polygon"),
                     _cmd_list)
     self.finish(cont=True)
Example #12
0
def format_object(target, origin=None):
    """Apply visual properties from the Draft toolbar or another object.

    This function only works if the graphical interface is available
    as the visual properties are attributes of the view provider
    (`obj.ViewObject`).

    Parameters
    ----------
    target: App::DocumentObject
        Any type of scripted object.

        This object will adopt the applicable visual properties,
        `FontSize`, `TextColor`, `LineWidth`, `PointColor`, `LineColor`,
        and `ShapeColor`, defined in the Draft toolbar
        (`Gui.draftToolBar`) or will adopt
        the properties from the `origin` object.

        The `target` is also placed in the construction group
        if the construction mode in the Draft toolbar is active.

    origin: App::DocumentObject, optional
        It defaults to `None`.
        If it exists, it will provide the visual properties to assign
        to `target`, with the exception of `BoundingBox`, `Proxy`,
        `RootNode` and `Visibility`.
    """
    if not target:
        return
    obrep = target.ViewObject
    if not obrep:
        return
    ui = None
    if App.GuiUp:
        if hasattr(Gui, "draftToolBar"):
            ui = Gui.draftToolBar
    if ui:
        doc = App.ActiveDocument
        if ui.isConstructionMode():
            col = fcol = ui.getDefaultColor("constr")
            gname = getParam("constructiongroupname", "Construction")
            grp = doc.getObject(gname)
            if not grp:
                grp = doc.addObject("App::DocumentObjectGroup", gname)
            grp.addObject(target)
            if hasattr(obrep, "Transparency"):
                obrep.Transparency = 80
        else:
            col = ui.getDefaultColor("ui")
            fcol = ui.getDefaultColor("face")
        col = (float(col[0]), float(col[1]), float(col[2]), 0.0)
        fcol = (float(fcol[0]), float(fcol[1]), float(fcol[2]), 0.0)
        lw = ui.linewidth
        fs = ui.fontsize
        if not origin or not hasattr(origin, 'ViewObject'):
            if "FontSize" in obrep.PropertiesList:
                obrep.FontSize = fs
            if "TextColor" in obrep.PropertiesList:
                obrep.TextColor = col
            if "LineWidth" in obrep.PropertiesList:
                obrep.LineWidth = lw
            if "PointColor" in obrep.PropertiesList:
                obrep.PointColor = col
            if "LineColor" in obrep.PropertiesList:
                obrep.LineColor = col
            if "ShapeColor" in obrep.PropertiesList:
                obrep.ShapeColor = fcol
        else:
            matchrep = origin.ViewObject
            for p in matchrep.PropertiesList:
                if p not in ("DisplayMode", "BoundingBox", "Proxy", "RootNode",
                             "Visibility"):
                    if p in obrep.PropertiesList:
                        if not obrep.getEditorMode(p):
                            if hasattr(getattr(matchrep, p), "Value"):
                                val = getattr(matchrep, p).Value
                            else:
                                val = getattr(matchrep, p)
                            try:
                                setattr(obrep, p, val)
                            except Exception:
                                pass
            if matchrep.DisplayMode in obrep.listDisplayModes():
                obrep.DisplayMode = matchrep.DisplayMode
            if (hasattr(matchrep, "DiffuseColor")
                    and hasattr(obrep, "DiffuseColor")):
                obrep.DiffuseColor = matchrep.DiffuseColor
Example #13
0
def dim_symbol(symbol=None, invert=False):
    """Return the specified dimension symbol.

    Parameters
    ----------
    symbol: int, optional
        It defaults to `None`, in which it gets the value from the parameter
        database, `get_param("dimsymbol", 0)`.

        A numerical value defines different markers
         * 0, `SoSphere`
         * 1, `SoMarkerSet` with a circle
         * 2, `SoSeparator` with a `soCone`
         * 3, `SoSeparator` with a `SoFaceSet`
         * 4, `SoSeparator` with a `SoLineSet`, calling `dim_dash`
         * Otherwise, `SoSphere`

    invert: bool, optional
        It defaults to `False`.
        If it is `True` and `symbol=2`, the cone will be rotated
        -90 degrees around the Z axis, otherwise the rotation is positive,
        +90 degrees.

    Returns
    -------
    Coin.SoNode
        A `Coin.SoSphere`, or `Coin.SoMarkerSet` (circle),
        or `Coin.SoSeparator` (cone, face, line)
        that will be used as a dimension symbol.
    """
    if symbol is None:
        symbol = getParam("dimsymbol", 0)

    if symbol == 0:
        return coin.SoSphere()
    elif symbol == 1:
        marker = coin.SoMarkerSet()
        marker.markerIndex = Gui.getMarkerIndex("circle", 9)
        return marker
    elif symbol == 2:
        marker = coin.SoSeparator()
        t = coin.SoTransform()
        t.translation.setValue((0, -2, 0))
        t.center.setValue((0, 2, 0))
        if invert:
            t.rotation.setValue(coin.SbVec3f((0, 0, 1)), -math.pi / 2)
        else:
            t.rotation.setValue(coin.SbVec3f((0, 0, 1)), math.pi / 2)
        c = coin.SoCone()
        c.height.setValue(4)
        marker.addChild(t)
        marker.addChild(c)
        return marker
    elif symbol == 3:
        marker = coin.SoSeparator()
        c = coin.SoCoordinate3()
        c.point.setValues([(-1, -2, 0), (0, 2, 0), (1, 2, 0), (0, -2, 0)])
        f = coin.SoFaceSet()
        marker.addChild(c)
        marker.addChild(f)
        return marker
    elif symbol == 4:
        return dimDash((-1.5, -1.5, 0), (1.5, 1.5, 0))
    else:
        _wrn(_tr("Symbol not implemented. Use a default symbol."))
        return coin.SoSphere()
Example #14
0
    def drawArc(self):
        """Actually draw the arc object."""
        rot, sup, pts, fil = self.getStrings()
        if self.closedCircle:
            try:
                # The command to run is built as a series of text strings
                # to be committed through the `draftutils.todo.ToDo` class.
                if utils.getParam("UsePartPrimitives", False):
                    # Insert a Part::Primitive object
                    _base = DraftVecUtils.toString(self.center)
                    _cmd = 'FreeCAD.ActiveDocument.'
                    _cmd += 'addObject("Part::Circle", "Circle")'
                    _cmd_list = ['circle = ' + _cmd,
                                 'circle.Radius = ' + str(self.rad),
                                 'pl = FreeCAD.Placement()',
                                 'pl.Rotation.Q = ' + rot,
                                 'pl.Base = ' + _base,
                                 'circle.Placement = pl',
                                 'Draft.autogroup(circle)',
                                 'FreeCAD.ActiveDocument.recompute()']
                    self.commit(translate("draft", "Create Circle (Part)"),
                                _cmd_list)
                else:
                    # Insert a Draft circle
                    Gui.addModule("Draft")
                    _base = DraftVecUtils.toString(self.center)
                    _cmd = 'Draft.makeCircle'
                    _cmd += '('
                    _cmd += 'radius=' + str(self.rad) + ', '
                    _cmd += 'placement=pl, '
                    _cmd += 'face=' + fil + ', '
                    _cmd += 'support=' + sup
                    _cmd += ')'
                    _cmd_list = ['pl=FreeCAD.Placement()',
                                 'pl.Rotation.Q=' + rot,
                                 'pl.Base=' + _base,
                                 'circle = ' + _cmd,
                                 'Draft.autogroup(circle)',
                                 'FreeCAD.ActiveDocument.recompute()']
                    self.commit(translate("draft", "Create Circle"),
                                _cmd_list)
            except Exception:
                _err("Draft: error delaying commit")
        else:
            # Not a closed circle, therefore a circular arc
            sta = math.degrees(self.firstangle)
            end = math.degrees(self.firstangle + self.angle)
            if end < sta:
                sta, end = end, sta
            while True:
                if sta > 360:
                    sta = sta - 360
                elif end > 360:
                    end = end - 360
                else:
                    break
            try:
                Gui.addModule("Draft")
                if utils.getParam("UsePartPrimitives", False):
                    # Insert a Part::Primitive object
                    _base = DraftVecUtils.toString(self.center)
                    _cmd = 'FreeCAD.ActiveDocument.'
                    _cmd += 'addObject("Part::Circle", "Circle")'
                    _cmd_list = ['circle = ' + _cmd,
                                 'circle.Radius = ' + str(self.rad),
                                 'circle.Angle0 = ' + str(sta),
                                 'circle.Angle1 = ' + str(end),
                                 'pl = FreeCAD.Placement()',
                                 'pl.Rotation.Q = ' + rot,
                                 'pl.Base = ' + _base,
                                 'circle.Placement = pl',
                                 'Draft.autogroup(circle)',
                                 'FreeCAD.ActiveDocument.recompute()']
                    self.commit(translate("draft", "Create Arc (Part)"),
                                _cmd_list)
                else:
                    # Insert a Draft circle
                    _base = DraftVecUtils.toString(self.center)
                    _cmd = 'Draft.makeCircle'
                    _cmd += '('
                    _cmd += 'radius=' + str(self.rad) + ', '
                    _cmd += 'placement=pl, '
                    _cmd += 'face=' + fil + ', '
                    _cmd += 'startangle=' + str(sta) + ', '
                    _cmd += 'endangle=' + str(end) + ', '
                    _cmd += 'support=' + sup
                    _cmd += ')'
                    _cmd_list = ['pl = FreeCAD.Placement()',
                                 'pl.Rotation.Q = ' + rot,
                                 'pl.Base = ' + _base,
                                 'circle = ' + _cmd,
                                 'Draft.autogroup(circle)',
                                 'FreeCAD.ActiveDocument.recompute()']
                    self.commit(translate("draft", "Create Arc"),
                                _cmd_list)
            except Exception:
                _err("Draft: error delaying commit")

        # Finalize full circle or cirular arc
        self.finish(cont=True)