FreeCAD

Форк
0
/
make_ellipse.py 
93 строки · 3.3 Кб
1
# ***************************************************************************
2
# *   Copyright (c) 2009, 2010 Yorik van Havre <yorik@uncreated.net>        *
3
# *   Copyright (c) 2009, 2010 Ken Cline <cline@frii.com>                   *
4
# *   Copyright (c) 2020 FreeCAD Developers                                 *
5
# *                                                                         *
6
# *   This program is free software; you can redistribute it and/or modify  *
7
# *   it under the terms of the GNU Lesser General Public License (LGPL)    *
8
# *   as published by the Free Software Foundation; either version 2 of     *
9
# *   the License, or (at your option) any later version.                   *
10
# *   for detail see the LICENCE text file.                                 *
11
# *                                                                         *
12
# *   This program is distributed in the hope that it will be useful,       *
13
# *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
14
# *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
15
# *   GNU Library General Public License for more details.                  *
16
# *                                                                         *
17
# *   You should have received a copy of the GNU Library General Public     *
18
# *   License along with this program; if not, write to the Free Software   *
19
# *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
20
# *   USA                                                                   *
21
# *                                                                         *
22
# ***************************************************************************
23
"""Provides functions to create Ellipse objects."""
24
## @package make_ellipse
25
# \ingroup draftmake
26
# \brief Provides functions to create Ellipse objects.
27

28
## \addtogroup draftmake
29
# @{
30
import FreeCAD as App
31
import draftutils.gui_utils as gui_utils
32

33
from draftobjects.ellipse import Ellipse
34

35
if App.GuiUp:
36
    from draftviewproviders.view_base import ViewProviderDraft
37

38

39
def make_ellipse(majradius, minradius, placement=None, face=None, support=None):
40
    """make_ellipse(majradius, minradius, [placement], [face], [support])
41

42
    Makes an ellipse with the given major and minor radius, and optionally
43
    a placement.
44

45
    Parameters
46
    ----------
47
    majradius :
48
        Major radius of the ellipse.
49

50
    minradius :
51
        Minor radius of the ellipse.
52

53
    placement : Base.Placement
54
        If a placement is given, it is used.
55

56
    face : Bool
57
        If face is False, the rectangle is shown as a wireframe,
58
        otherwise as a face.
59

60
    support :
61
        TODO: Describe.
62
    """
63

64
    if not App.ActiveDocument:
65
        App.Console.PrintError("No active document. Aborting\n")
66
        return
67

68
    obj = App.ActiveDocument.addObject("Part::Part2DObjectPython", "Ellipse")
69
    Ellipse(obj)
70

71
    if minradius > majradius:
72
        majradius, minradius = minradius, majradius
73
    obj.MajorRadius = majradius
74
    obj.MinorRadius = minradius
75
    obj.AttachmentSupport = support
76

77
    if face is not None:
78
        obj.MakeFace = face
79

80
    if placement:
81
        obj.Placement = placement
82

83
    if App.GuiUp:
84
        ViewProviderDraft(obj.ViewObject)
85
        gui_utils.format_object(obj)
86
        gui_utils.select(obj)
87

88
    return obj
89

90

91
makeEllipse = make_ellipse
92

93
## @}
94

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.