diff --git a/src/Mod/Draft/CMakeLists.txt b/src/Mod/Draft/CMakeLists.txt index 8d87253aa5..ff65f9698b 100644 --- a/src/Mod/Draft/CMakeLists.txt +++ b/src/Mod/Draft/CMakeLists.txt @@ -60,6 +60,7 @@ SET(Draft_utilities SET(Draft_functions draftfunctions/__init__.py + draftfunctions/cut.py draftfunctions/draftify.py draftfunctions/fuse.py draftfunctions/heal.py diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py index f778118fa9..7f793e869e 100644 --- a/src/Mod/Draft/Draft.py +++ b/src/Mod/Draft/Draft.py @@ -179,6 +179,8 @@ from draftutils.gui_utils import load_texture # Draft functions #--------------------------------------------------------------------------- +from draftfunctions.cut import cut + from draftfunctions.draftify import draftify from draftfunctions.fuse import fuse @@ -516,22 +518,6 @@ def extrude(obj,vector,solid=False): return newobj -def cut(object1,object2): - """cut(oject1,object2): returns a cut object made from - the difference of the 2 given objects.""" - if not FreeCAD.ActiveDocument: - FreeCAD.Console.PrintError("No active document. Aborting\n") - return - obj = FreeCAD.ActiveDocument.addObject("Part::Cut","Cut") - obj.Base = object1 - obj.Tool = object2 - object1.ViewObject.Visibility = False - object2.ViewObject.Visibility = False - formatObject(obj, object1) - select(obj) - - return obj - def moveVertex(object, vertex_index, vector): points = object.Points points[vertex_index] = points[vertex_index].add(vector) diff --git a/src/Mod/Draft/draftfunctions/cut.py b/src/Mod/Draft/draftfunctions/cut.py new file mode 100644 index 0000000000..d48cb3673c --- /dev/null +++ b/src/Mod/Draft/draftfunctions/cut.py @@ -0,0 +1,51 @@ +# *************************************************************************** +# * Copyright (c) 2009, 2010 Yorik van Havre * +# * Copyright (c) 2009, 2010 Ken Cline * +# * Copyright (c) 2020 FreeCAD Developers * +# * * +# * This program is free software; you can redistribute it and/or modify * +# * it under the terms of the GNU Lesser General Public License (LGPL) * +# * as published by the Free Software Foundation; either version 2 of * +# * the License, or (at your option) any later version. * +# * for detail see the LICENCE text file. * +# * * +# * This program is distributed in the hope that it will be useful, * +# * but WITHOUT ANY WARRANTY; without even the implied warranty of * +# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# * GNU Library General Public License for more details. * +# * * +# * You should have received a copy of the GNU Library General Public * +# * License along with this program; if not, write to the Free Software * +# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +# * USA * +# * * +# *************************************************************************** +"""This module provides the code for Draft cut function. +""" +## @package cut +# \ingroup DRAFT +# \brief This module provides the code for Draft cut function. + +import FreeCAD as App + +import draftutils.gui_utils as gui_utils + + +def cut(object1,object2): + """cut(oject1,object2) + + Returns a cut object made from the difference of the 2 given objects. + """ + if not App.ActiveDocument: + App.Console.PrintError("No active document. Aborting\n") + return + obj = App.ActiveDocument.addObject("Part::Cut","Cut") + obj.Base = object1 + obj.Tool = object2 + object1.ViewObject.Visibility = False + object2.ViewObject.Visibility = False + if App.GuiUp: + gui_utils.format_object(obj, object1) + gui_utils.select(obj) + + return obj