improvement to Cut Plane

Move cut plane on itw own.
Add ArchCutPlan to CmakeList
Add task panel
Add choice between side of the face
This commit is contained in:
wood galaxy 2014-11-17 15:44:11 +01:00
parent 86a1757c20
commit e070a717a5
4 changed files with 103 additions and 33 deletions

View File

@ -1,7 +1,7 @@
#***************************************************************************
#* *
#* Copyright (c) 2011 *
#* Yorik van Havre <yorik@uncreated.net> *
#* Copyright (c) 2011 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
@ -46,3 +46,4 @@ from ArchRebar import *
from ArchFrame import *
from ArchPanel import *
from ArchEquipment import *
from ArchCutPlane import *

View File

@ -393,16 +393,6 @@ def getCutVolume(cutplane,shapes):
invcutvolume = cutface.extrude(cutnormal)
return cutface,cutvolume,invcutvolume
def cutComponent(cutPlane, archObject):
"""cut object from a plan"""
cutVolume = getCutVolume(cutPlane, archObject.Object.Shape)
cutVolume = cutVolume[2]
if cutVolume:
obj = FreeCAD.ActiveDocument.addObject("Part::Feature", "CutVolume")
obj.Shape = cutVolume
# add substraction component to Arch object
return removeComponents(obj,archObject.Object)
def getShapeFromMesh(mesh,fast=True,tolerance=0.001,flat=False,cut=True):
import Part, MeshPart, DraftGeomUtils
if mesh.isSolid() and (mesh.countComponents() == 1) and fast:
@ -942,26 +932,6 @@ class _CommandRemove:
FreeCAD.ActiveDocument.recompute()
class _CommandCutPlane:
"the Arch CutPlane command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_CutPlane',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_CutPlane","Cut object"),
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_CutPlane","Cut the object with plane")}
def IsActive(self):
return len(FreeCADGui.Selection.getSelection()) > 1
def Activated(self):
face = FreeCADGui.Selection.getSelectionEx()[1].SubObjects[0]
archObject = FreeCADGui.Selection.getSelectionEx()[0]
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Cutting")))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.cutComponent(FreeCADGui.Selection.getSelectionEx()[1].SubObjects[0],FreeCADGui.Selection.getSelectionEx()[0])")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
class _CommandSplitMesh:
"the Arch SplitMesh command definition"
def GetResources(self):
@ -1148,7 +1118,6 @@ class _ToggleIfcBrepFlag:
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_Add',_CommandAdd())
FreeCADGui.addCommand('Arch_Remove',_CommandRemove())
FreeCADGui.addCommand('Arch_CutPlane',_CommandCutPlane())
FreeCADGui.addCommand('Arch_SplitMesh',_CommandSplitMesh())
FreeCADGui.addCommand('Arch_MeshToShape',_CommandMeshToShape())
FreeCADGui.addCommand('Arch_SelectNonSolidMeshes',_CommandSelectNonSolidMeshes())

View File

@ -0,0 +1,99 @@
#***************************************************************************
#* *
#* Copyright (c) 2014 *
#* Jonathan Wiedemann <wood.galaxy@gmail.com> *
#* *
#* 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 *
#* *
#***************************************************************************
import FreeCAD,ArchCommands
from FreeCAD import Vector
if FreeCAD.GuiUp:
import FreeCADGui
from PySide import QtCore, QtGui
from DraftTools import translate
else:
def translate(ctxt,txt):
return txt
__title__="FreeCAD CutPlane"
__author__ = "Jonathan Wiedemann"
__url__ = "http://www.freecadweb.org"
# Couper
def cutComponentwithPlane(archObject, cutPlane, sideFace):
"""cut object from a plan define by a face, Behind = 0 , front = 1"""
cutVolume = ArchCommands.getCutVolume(cutPlane, archObject.Object.Shape)
if sideFace == 0:
cutVolume = cutVolume[2]
else:
cutVolume = cutVolume[1]
if cutVolume:
obj = FreeCAD.ActiveDocument.addObject("Part::Feature", "CutVolume")
obj.Shape = cutVolume
# add substraction component to Arch object
return ArchCommands.removeComponents(obj,archObject.Object)
class _CommandCutPlane:
"the Arch CutPlane command definition"
def GetResources(self):
return {'Pixmap' : 'Arch_CutPlane',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_CutPlane","Cut object"),
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_CutPlane","Cut the object with plane")}
def IsActive(self):
return len(FreeCADGui.Selection.getSelection()) > 1
def Activated(self):
panel=_CutPlaneTaskPanel()
FreeCADGui.Control.showDialog(panel)
class _CutPlaneTaskPanel:
def __init__(self):
self.title = QtGui.QLabel('Cut Plane options')
self.infoText = QtGui.QLabel('Wich side')
self.grid = QtGui.QGridLayout()
self.grid.addWidget(self.title, 1, 0)
self.grid.addWidget(self.infoText, 2, 0)
self.combobox = QtGui.QComboBox()
items = ["Behind","Front"]
self.combobox.addItems(items)
self.combobox.setCurrentIndex(items.index("Behind"))
self.grid.addWidget(self.combobox, 2, 1)
groupBox = QtGui.QGroupBox()
groupBox.setLayout(self.grid)
self.form = groupBox
def accept(self):
val = self.combobox.currentIndex()
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Cutting")))
FreeCADGui.addModule("Arch")
FreeCADGui.doCommand("Arch.cutComponentwithPlane(FreeCADGui.Selection.getSelectionEx()[0],FreeCADGui.Selection.getSelectionEx()[1].SubObjects[0],"+ str(val) +")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
return True
def reject(self):
FreeCAD.Console.PrintMessage("Cancel Cut Plane\n")
return True
def getStandardButtons(self):
return int(QtGui.QDialogButtonBox.Ok|QtGui.QDialogButtonBox.Cancel)
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Arch_CutPlane',_CommandCutPlane())

View File

@ -28,6 +28,7 @@ SET(Arch_SRCS
ArchFrame.py
ArchPanel.py
ArchEquipment.py
ArchCutPlane.py
)
SOURCE_GROUP("" FILES ${Arch_SRCS})