Files
create/src/Mod/Draft/draftfunctions/cut.py
vocx-fc 1d48e9fb47 Draft: add modules of draftfunctions to the proper Doxygen group
This includes `array`, `cut`, `downgrade`, `draftiffy`, `extrude`,
`fuse`, `heal`, `join`, `mirror`, `move`, `offset`, `rotate`,
`scale`, `split` and `upgrade`.

These are added to the `draftfunction` Doxygen group
so that the functions contained in each module are listed
appropriately in the automatically generated documentation.
2020-07-17 13:01:45 +02:00

73 lines
2.9 KiB
Python

# ***************************************************************************
# * Copyright (c) 2009, 2010 Yorik van Havre <yorik@uncreated.net> *
# * Copyright (c) 2009, 2010 Ken Cline <cline@frii.com> *
# * Copyright (c) 2020 Eliud Cabrera Castillo <e.cabrera-castillo@tum.de> *
# * *
# * 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 *
# * *
# ***************************************************************************
"""Provides functions to create a cut object from two objects."""
## @package cut
# \ingroup draftfuctions
# \brief Provides functions to create a cut object from two objects.
## \addtogroup draftfuctions
# @{
import FreeCAD as App
import draftutils.gui_utils as gui_utils
from draftutils.translate import _tr
from draftutils.messages import _err
def cut(object1, object2):
"""Return a cut object made from the difference of the 2 given objects.
Parameters
----------
object1: Part::Feature
Any object with a `Part::TopoShape`.
object2: Part::Feature
Any object with a `Part::TopoShape`.
Returns
-------
Part::Cut
The resulting cut object.
None
If there is a problem and the new object can't be created.
"""
if not App.activeDocument():
_err(_tr("No active document. Aborting."))
return
obj = App.activeDocument().addObject("Part::Cut", "Cut")
obj.Base = object1
obj.Tool = object2
if App.GuiUp:
gui_utils.format_object(obj, object1)
gui_utils.select(obj)
object1.ViewObject.Visibility = False
object2.ViewObject.Visibility = False
return obj
## @}