Arch: Added Depth property to SectionPlanes
This commit is contained in:
@@ -398,10 +398,11 @@ def closeHole(shape):
|
||||
else:
|
||||
return solid
|
||||
|
||||
def getCutVolume(cutplane,shapes,clip=False):
|
||||
"""getCutVolume(cutplane,shapes,[clip]): returns a cut face and a cut volume
|
||||
def getCutVolume(cutplane,shapes,clip=False,depth=None):
|
||||
"""getCutVolume(cutplane,shapes,[clip,depth]): returns a cut face and a cut volume
|
||||
from the given shapes and the given cutting plane. If clip is True, the cutvolume will
|
||||
also cut off everything outside the cutplane projection"""
|
||||
also cut off everything outside the cutplane projection. If depth is non-zero, geometry
|
||||
further than this distance will be clipped off"""
|
||||
if not shapes:
|
||||
return None,None,None
|
||||
if not cutplane.Faces:
|
||||
@@ -470,6 +471,12 @@ def getCutVolume(cutplane,shapes,clip=False):
|
||||
cutvolume = cutvolume.removeSplitter()
|
||||
invcutvolume = extrudedplane
|
||||
cutface = p
|
||||
if depth:
|
||||
depthnormal = DraftVecUtils.scaleTo(cutnormal,depth)
|
||||
depthvolume = cutface.extrude(depthnormal)
|
||||
depthclipvolume = invcutvolume.cut(depthvolume)
|
||||
cutvolume = cutvolume.fuse(depthclipvolume)
|
||||
cutvolume = cutvolume.removeSplitter()
|
||||
return cutface,cutvolume,invcutvolume
|
||||
|
||||
def getShapeFromMesh(mesh,fast=True,tolerance=0.001,flat=False,cut=True):
|
||||
|
||||
@@ -929,6 +929,8 @@ class _SectionPlane:
|
||||
if not "UseMaterialColorForFill" in pl:
|
||||
obj.addProperty("App::PropertyBool","UseMaterialColorForFill","SectionPlane",QT_TRANSLATE_NOOP("App::Property","If true, the color of the objects material will be used to fill cut areas."))
|
||||
obj.UseMaterialColorForFill = False
|
||||
if not "Depth" in pl:
|
||||
obj.addProperty("App::PropertyLength","Depth","SectionPlane",QT_TRANSLATE_NOOP("App::Property","Geometry further than this value will be cut off. Keep zero for unlimited."))
|
||||
self.Type = "SectionPlane"
|
||||
|
||||
def onDocumentRestored(self,obj):
|
||||
|
||||
@@ -44,75 +44,96 @@ class Shape2DView(DraftObject):
|
||||
|
||||
def __init__(self,obj):
|
||||
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
"The base object this 2D view must represent")
|
||||
obj.addProperty("App::PropertyLink", "Base",
|
||||
"Draft", _tip)
|
||||
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
"The projection vector of this object")
|
||||
obj.addProperty("App::PropertyVector", "Projection",
|
||||
"Draft", _tip)
|
||||
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
"The way the viewed object must be projected")
|
||||
obj.addProperty("App::PropertyEnumeration", "ProjectionMode",
|
||||
"Draft", _tip)
|
||||
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
"The indices of the faces to be projected in Individual Faces mode")
|
||||
obj.addProperty("App::PropertyIntegerList", "FaceNumbers",
|
||||
"Draft", _tip)
|
||||
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
"Show hidden lines")
|
||||
obj.addProperty("App::PropertyBool", "HiddenLines",
|
||||
"Draft", _tip)
|
||||
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
"Fuse wall and structure objects of same type and material")
|
||||
obj.addProperty("App::PropertyBool", "FuseArch",
|
||||
"Draft", _tip)
|
||||
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
"Tessellate Ellipses and B-splines into line segments")
|
||||
obj.addProperty("App::PropertyBool", "Tessellation",
|
||||
"Draft", _tip)
|
||||
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
"For Cutlines and Cutfaces modes, \
|
||||
this leaves the faces at the cut location")
|
||||
obj.addProperty("App::PropertyBool", "InPlace",
|
||||
"Draft", _tip)
|
||||
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
"Length of line segments if tessellating Ellipses or B-splines \
|
||||
into line segments")
|
||||
obj.addProperty("App::PropertyFloat", "SegmentLength",
|
||||
"Draft", _tip)
|
||||
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
"If this is True, this object will be recomputed only if it is \
|
||||
visible")
|
||||
obj.addProperty("App::PropertyBool", "VisibleOnly",
|
||||
"Draft", _tip)
|
||||
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
"A list of exclusion points. Any edge touching any of those points will not be drawn.")
|
||||
obj.addProperty("App::PropertyVectorList", "ExclusionPoints",
|
||||
"Draft", _tip)
|
||||
|
||||
obj.Projection = App.Vector(0,0,1)
|
||||
obj.ProjectionMode = ["Solid", "Individual Faces",
|
||||
"Cutlines", "Cutfaces","Solid faces"]
|
||||
obj.HiddenLines = False
|
||||
obj.Tessellation = False
|
||||
obj.VisibleOnly = False
|
||||
obj.InPlace = True
|
||||
obj.SegmentLength = .05
|
||||
self.setProperties(obj)
|
||||
super(Shape2DView, self).__init__(obj, "Shape2DView")
|
||||
|
||||
def setProperties(self,obj):
|
||||
|
||||
pl = obj.PropertiesList
|
||||
|
||||
if not "Base" in pl:
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
"The base object this 2D view must represent")
|
||||
obj.addProperty("App::PropertyLink", "Base",
|
||||
"Draft", _tip)
|
||||
if not "Projection" in pl:
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
"The projection vector of this object")
|
||||
obj.addProperty("App::PropertyVector", "Projection",
|
||||
"Draft", _tip)
|
||||
obj.Projection = App.Vector(0,0,1)
|
||||
if not "ProjectionMode" in pl:
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
"The way the viewed object must be projected")
|
||||
obj.addProperty("App::PropertyEnumeration", "ProjectionMode",
|
||||
"Draft", _tip)
|
||||
obj.ProjectionMode = ["Solid", "Individual Faces",
|
||||
"Cutlines", "Cutfaces","Solid faces"]
|
||||
if not "FaceNumbers" in pl:
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
"The indices of the faces to be projected in Individual Faces mode")
|
||||
obj.addProperty("App::PropertyIntegerList", "FaceNumbers",
|
||||
"Draft", _tip)
|
||||
if not "HiddenLines" in pl:
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
"Show hidden lines")
|
||||
obj.addProperty("App::PropertyBool", "HiddenLines",
|
||||
"Draft", _tip)
|
||||
obj.HiddenLines = False
|
||||
if not "FuseArch" in pl:
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
"Fuse wall and structure objects of same type and material")
|
||||
obj.addProperty("App::PropertyBool", "FuseArch",
|
||||
"Draft", _tip)
|
||||
if not "Tessellation" in pl:
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
"Tessellate Ellipses and B-splines into line segments")
|
||||
obj.addProperty("App::PropertyBool", "Tessellation",
|
||||
"Draft", _tip)
|
||||
obj.Tessellation = False
|
||||
if not "InPlace" in pl:
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
"For Cutlines and Cutfaces modes, \
|
||||
this leaves the faces at the cut location")
|
||||
obj.addProperty("App::PropertyBool", "InPlace",
|
||||
"Draft", _tip)
|
||||
obj.InPlace = True
|
||||
if not "SegmentLength" in pl:
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
"Length of line segments if tessellating Ellipses or B-splines \
|
||||
into line segments")
|
||||
obj.addProperty("App::PropertyFloat", "SegmentLength",
|
||||
"Draft", _tip)
|
||||
obj.SegmentLength = .05
|
||||
if not "VisibleOnly" in pl:
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
"If this is True, this object will be recomputed only if it is \
|
||||
visible")
|
||||
obj.addProperty("App::PropertyBool", "VisibleOnly",
|
||||
"Draft", _tip)
|
||||
obj.VisibleOnly = False
|
||||
if not "ExclusionPoints" in pl:
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
"A list of exclusion points. Any edge touching any of those points will not be drawn.")
|
||||
obj.addProperty("App::PropertyVectorList", "ExclusionPoints",
|
||||
"Draft", _tip)
|
||||
if not "OnlySolids" in pl:
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
"If this is True, only solid geometry is handled. This overrides the base object's Only Solids property")
|
||||
obj.addProperty("App::PropertyBool", "OnlySolids",
|
||||
"Draft", _tip)
|
||||
if not "Clip" in pl:
|
||||
_tip = QT_TRANSLATE_NOOP("App::Property",
|
||||
"If this is True, the contents are clipped to the borders of the section plane, if applicable. This overrides the base object's Clip property")
|
||||
obj.addProperty("App::PropertyBool", "Clip",
|
||||
"Draft", _tip)
|
||||
|
||||
def onDocumentRestored(self, obj):
|
||||
|
||||
self.setProperties(obj)
|
||||
|
||||
def getProjected(self,obj,shape,direction):
|
||||
|
||||
"returns projected edges from a shape and a direction"
|
||||
import Part, Drawing, DraftGeomUtils
|
||||
edges = []
|
||||
@@ -135,6 +156,7 @@ class Shape2DView(DraftObject):
|
||||
#return DraftGeomUtils.cleanProjection(Part.makeCompound(edges))
|
||||
|
||||
def cleanExcluded(self,obj,shapes):
|
||||
|
||||
"""removes any edge touching exclusion points"""
|
||||
import Part
|
||||
MAXDIST = 0.0001
|
||||
@@ -183,9 +205,12 @@ class Shape2DView(DraftObject):
|
||||
onlysolids = True
|
||||
if hasattr(obj.Base,"OnlySolids"):
|
||||
onlysolids = obj.Base.OnlySolids
|
||||
if hasattr(obj,"OnlySolids"): # override base object
|
||||
onlysolids = obj.OnlySolids
|
||||
import Arch, Part, Drawing
|
||||
objs = groups.get_group_contents(objs, walls=True)
|
||||
objs = gui_utils.remove_hidden(objs)
|
||||
if getattr(obj,"VisibleOnly",True):
|
||||
objs = gui_utils.remove_hidden(objs)
|
||||
shapes = []
|
||||
if hasattr(obj,"FuseArch") and obj.FuseArch:
|
||||
shtypes = {}
|
||||
@@ -224,7 +249,12 @@ class Shape2DView(DraftObject):
|
||||
clip = False
|
||||
if hasattr(obj.Base,"Clip"):
|
||||
clip = obj.Base.Clip
|
||||
cutp, cutv, iv = Arch.getCutVolume(cutplane, shapes, clip)
|
||||
if hasattr(obj,"Clip"): #override base object
|
||||
clip = obj.Clip
|
||||
depth = None
|
||||
if hasattr(obj.Base,"Depth"):
|
||||
depth = obj.Base.Depth.Value
|
||||
cutp, cutv, iv = Arch.getCutVolume(cutplane, shapes, clip, depth)
|
||||
cuts = []
|
||||
opl = App.Placement(obj.Base.Placement)
|
||||
proj = opl.Rotation.multVec(App.Vector(0, 0, 1))
|
||||
|
||||
Reference in New Issue
Block a user