Draft: split cut from Draft.py

This commit is contained in:
carlopav
2020-04-26 15:00:30 +02:00
committed by Yorik van Havre
parent 08448d198e
commit f0136fd27d
3 changed files with 54 additions and 16 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -0,0 +1,51 @@
# ***************************************************************************
# * Copyright (c) 2009, 2010 Yorik van Havre <yorik@uncreated.net> *
# * Copyright (c) 2009, 2010 Ken Cline <cline@frii.com> *
# * 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