FreeCAD
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 Shape2DView objects."""
24## @package make_shape2dview
25# \ingroup draftmake
26# \brief Provides functions to create Shape2DView objects.
27
28## \addtogroup draftmake
29# @{
30import FreeCAD as App31import draftutils.gui_utils as gui_utils32
33from draftobjects.shape2dview import Shape2DView34
35if App.GuiUp:36from draftviewproviders.view_base import ViewProviderDraftAlt37
38
39def make_shape2dview(baseobj,projectionVector=None,facenumbers=[]):40"""make_shape2dview(object, [projectionVector], [facenumbers])41
42Add a 2D shape to the document, which is a 2D projection of the given object.
43
44Parameters
45----------
46object :
47TODO: Describe
48
49projectionVector : Base.Vector
50Custom vector for the projection
51
52facenumbers : [] TODO: Describe
53A list of face numbers to be considered in individual faces mode.
54"""
55if not App.ActiveDocument:56App.Console.PrintError("No active document. Aborting\n")57return58obj = App.ActiveDocument.addObject("Part::Part2DObjectPython","Shape2DView")59Shape2DView(obj)60if App.GuiUp:61ViewProviderDraftAlt(obj.ViewObject)62obj.Base = baseobj63if projectionVector:64obj.Projection = projectionVector65if facenumbers:66obj.FaceNumbers = facenumbers67gui_utils.select(obj)68
69return obj70
71
72makeShape2DView = make_shape2dview73
74## @}
75