FreeCAD

Форк
0
/
make_line.py 
72 строки · 3.1 Кб
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 two-point Wire objects."""
24
## @package make_line
25
# \ingroup draftmake
26
# \brief Provides functions to create two-point Wire objects.
27

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

33

34
def make_line(first_param, last_param=None):
35
    """makeLine(first_param, p2)
36

37
    Creates a line from 2 points or from a given object.
38

39
    Parameters
40
    ----------
41
    first_param :
42
        Base.Vector -> First point of the line (if p2 is None)
43
        Part.LineSegment -> Line is created from the given Linesegment
44
        Shape -> Line is created from the give Shape
45

46
    last_param : Base.Vector
47
        Second point of the line, if not set the function evaluates
48
        the first_param to look for a Part.LineSegment or a Shape
49
    """
50
    if last_param:
51
        p1 = first_param
52
        p2 = last_param
53
    else:
54
        if hasattr(first_param, "StartPoint") and hasattr(first_param, "EndPoint"):
55
            p2 = first_param.EndPoint
56
            p1 = first_param.StartPoint
57
        elif hasattr(p1,"Vertexes"):
58
            p2 = first_param.Vertexes[-1].Point
59
            p1 = first_param.Vertexes[0].Point
60
        else:
61
            _err = "Unable to create a line from the given parameters"
62
            App.Console.PrintError(_err + "\n")
63
            return
64

65
    obj = make_wire.make_wire([p1,p2])
66

67
    return obj
68

69

70
makeLine = make_line
71

72
## @}
73

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

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

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

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