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 *
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. *
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. *
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 *
22
# ***************************************************************************
23
"""Provides functions to create two-point Wire objects."""
26
# \brief Provides functions to create two-point Wire objects.
28
## \addtogroup draftmake
31
import draftmake.make_wire as make_wire
34
def make_line(first_param, last_param=None):
35
"""makeLine(first_param, p2)
37
Creates a line from 2 points or from a given object.
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
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
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
61
_err = "Unable to create a line from the given parameters"
62
App.Console.PrintError(_err + "\n")
65
obj = make_wire.make_wire([p1,p2])