Draft: Filling objects with faces is now optional - fixes #1395
Closable Draft objects now have a new MakeFace property, that specifies if they must be turned into a face or stay a wire only. Older Draft objects continue to behave the old way for compatibility. The default behaviour can be set in Draft Preferences -> Fill objects with faces
This commit is contained in:
parent
78a36e4e9a
commit
96bba087eb
|
@ -573,6 +573,7 @@ def makeCircle(radius, placement=None, face=True, startangle=None, endangle=None
|
||||||
n = "Circle"
|
n = "Circle"
|
||||||
obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython",n)
|
obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython",n)
|
||||||
_Circle(obj)
|
_Circle(obj)
|
||||||
|
obj.MakeFace = face
|
||||||
if isinstance(radius,Part.Edge):
|
if isinstance(radius,Part.Edge):
|
||||||
edge = radius
|
edge = radius
|
||||||
if DraftGeomUtils.geomType(edge) == "Circle":
|
if DraftGeomUtils.geomType(edge) == "Circle":
|
||||||
|
@ -598,7 +599,6 @@ def makeCircle(radius, placement=None, face=True, startangle=None, endangle=None
|
||||||
if placement: obj.Placement = placement
|
if placement: obj.Placement = placement
|
||||||
if gui:
|
if gui:
|
||||||
_ViewProviderDraft(obj.ViewObject)
|
_ViewProviderDraft(obj.ViewObject)
|
||||||
if not face: obj.ViewObject.DisplayMode = "Wireframe"
|
|
||||||
formatObject(obj)
|
formatObject(obj)
|
||||||
select(obj)
|
select(obj)
|
||||||
FreeCAD.ActiveDocument.recompute()
|
FreeCAD.ActiveDocument.recompute()
|
||||||
|
@ -616,10 +616,10 @@ def makeRectangle(length, height, placement=None, face=True, support=None):
|
||||||
obj.Length = length
|
obj.Length = length
|
||||||
obj.Height = height
|
obj.Height = height
|
||||||
obj.Support = support
|
obj.Support = support
|
||||||
|
obj.MakeFace = face
|
||||||
if placement: obj.Placement = placement
|
if placement: obj.Placement = placement
|
||||||
if gui:
|
if gui:
|
||||||
_ViewProviderRectangle(obj.ViewObject)
|
_ViewProviderRectangle(obj.ViewObject)
|
||||||
if not face: obj.ViewObject.DisplayMode = "Wireframe"
|
|
||||||
formatObject(obj)
|
formatObject(obj)
|
||||||
select(obj)
|
select(obj)
|
||||||
FreeCAD.ActiveDocument.recompute()
|
FreeCAD.ActiveDocument.recompute()
|
||||||
|
@ -752,10 +752,10 @@ def makeWire(pointslist,closed=False,placement=None,face=True,support=None):
|
||||||
obj.Points = pointslist
|
obj.Points = pointslist
|
||||||
obj.Closed = closed
|
obj.Closed = closed
|
||||||
obj.Support = support
|
obj.Support = support
|
||||||
|
obj.MakeFace = face
|
||||||
if placement: obj.Placement = placement
|
if placement: obj.Placement = placement
|
||||||
if gui:
|
if gui:
|
||||||
_ViewProviderWire(obj.ViewObject)
|
_ViewProviderWire(obj.ViewObject)
|
||||||
if not face: obj.ViewObject.DisplayMode = "Wireframe"
|
|
||||||
formatObject(obj)
|
formatObject(obj)
|
||||||
select(obj)
|
select(obj)
|
||||||
FreeCAD.ActiveDocument.recompute()
|
FreeCAD.ActiveDocument.recompute()
|
||||||
|
@ -773,6 +773,7 @@ def makePolygon(nfaces,radius=1,inscribed=True,placement=None,face=True,support=
|
||||||
_Polygon(obj)
|
_Polygon(obj)
|
||||||
obj.FacesNumber = nfaces
|
obj.FacesNumber = nfaces
|
||||||
obj.Radius = radius
|
obj.Radius = radius
|
||||||
|
obj.MakeFace = face
|
||||||
if inscribed:
|
if inscribed:
|
||||||
obj.DrawMode = "inscribed"
|
obj.DrawMode = "inscribed"
|
||||||
else:
|
else:
|
||||||
|
@ -781,7 +782,6 @@ def makePolygon(nfaces,radius=1,inscribed=True,placement=None,face=True,support=
|
||||||
if placement: obj.Placement = placement
|
if placement: obj.Placement = placement
|
||||||
if gui:
|
if gui:
|
||||||
_ViewProviderDraft(obj.ViewObject)
|
_ViewProviderDraft(obj.ViewObject)
|
||||||
if not face: obj.ViewObject.DisplayMode = "Wireframe"
|
|
||||||
formatObject(obj)
|
formatObject(obj)
|
||||||
select(obj)
|
select(obj)
|
||||||
FreeCAD.ActiveDocument.recompute()
|
FreeCAD.ActiveDocument.recompute()
|
||||||
|
@ -824,16 +824,16 @@ def makeBSpline(pointslist,closed=False,placement=None,face=True,support=None):
|
||||||
obj.Closed = closed
|
obj.Closed = closed
|
||||||
obj.Points = pointslist
|
obj.Points = pointslist
|
||||||
obj.Support = support
|
obj.Support = support
|
||||||
|
obj.MakeFace = face
|
||||||
if placement: obj.Placement = placement
|
if placement: obj.Placement = placement
|
||||||
if gui:
|
if gui:
|
||||||
_ViewProviderWire(obj.ViewObject)
|
_ViewProviderWire(obj.ViewObject)
|
||||||
if not face: obj.ViewObject.DisplayMode = "Wireframe"
|
|
||||||
formatObject(obj)
|
formatObject(obj)
|
||||||
select(obj)
|
select(obj)
|
||||||
FreeCAD.ActiveDocument.recompute()
|
FreeCAD.ActiveDocument.recompute()
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
def makeBezCurve(pointslist,closed=False,placement=None,support=None,Degree=None):
|
def makeBezCurve(pointslist,closed=False,placement=None,face=True,support=None,Degree=None):
|
||||||
'''makeBezCurve(pointslist,[closed],[placement]): Creates a Bezier Curve object
|
'''makeBezCurve(pointslist,[closed],[placement]): Creates a Bezier Curve object
|
||||||
from the given list of vectors. Instead of a pointslist, you can also pass a Part Wire.'''
|
from the given list of vectors. Instead of a pointslist, you can also pass a Part Wire.'''
|
||||||
if not isinstance(pointslist,list):
|
if not isinstance(pointslist,list):
|
||||||
|
@ -855,12 +855,13 @@ def makeBezCurve(pointslist,closed=False,placement=None,support=None,Degree=None
|
||||||
Part.BezierCurve().MaxDegree)
|
Part.BezierCurve().MaxDegree)
|
||||||
obj.Closed = closed
|
obj.Closed = closed
|
||||||
obj.Support = support
|
obj.Support = support
|
||||||
|
obj.MakeFace = face
|
||||||
obj.Proxy.resetcontinuity(obj)
|
obj.Proxy.resetcontinuity(obj)
|
||||||
if placement: obj.Placement = placement
|
if placement: obj.Placement = placement
|
||||||
if gui:
|
if gui:
|
||||||
_ViewProviderWire(obj.ViewObject)
|
_ViewProviderWire(obj.ViewObject)
|
||||||
# if not face: obj.ViewObject.DisplayMode = "Wireframe"
|
# if not face: obj.ViewObject.DisplayMode = "Wireframe"
|
||||||
obj.ViewObject.DisplayMode = "Wireframe"
|
# obj.ViewObject.DisplayMode = "Wireframe"
|
||||||
formatObject(obj)
|
formatObject(obj)
|
||||||
select(obj)
|
select(obj)
|
||||||
FreeCAD.ActiveDocument.recompute()
|
FreeCAD.ActiveDocument.recompute()
|
||||||
|
@ -3684,6 +3685,8 @@ class _Rectangle(_DraftObject):
|
||||||
obj.addProperty("App::PropertyDistance","Height","Draft","Height of the rectange")
|
obj.addProperty("App::PropertyDistance","Height","Draft","Height of the rectange")
|
||||||
obj.addProperty("App::PropertyLength","FilletRadius","Draft","Radius to use to fillet the corners")
|
obj.addProperty("App::PropertyLength","FilletRadius","Draft","Radius to use to fillet the corners")
|
||||||
obj.addProperty("App::PropertyLength","ChamferSize","Draft","Size of the chamfer to give to the corners")
|
obj.addProperty("App::PropertyLength","ChamferSize","Draft","Size of the chamfer to give to the corners")
|
||||||
|
obj.addProperty("App::PropertyBool","MakeFace","Draft","Create a face")
|
||||||
|
obj.MakeFace = True
|
||||||
obj.Length=1
|
obj.Length=1
|
||||||
obj.Height=1
|
obj.Height=1
|
||||||
|
|
||||||
|
@ -3706,6 +3709,10 @@ class _Rectangle(_DraftObject):
|
||||||
w = DraftGeomUtils.filletWire(shape,obj.FilletRadius.Value)
|
w = DraftGeomUtils.filletWire(shape,obj.FilletRadius.Value)
|
||||||
if w:
|
if w:
|
||||||
shape = w
|
shape = w
|
||||||
|
if hasattr(obj,"MakeFace"):
|
||||||
|
if obj.MakeFace:
|
||||||
|
shape = Part.Face(shape)
|
||||||
|
else:
|
||||||
shape = Part.Face(shape)
|
shape = Part.Face(shape)
|
||||||
obj.Shape = shape
|
obj.Shape = shape
|
||||||
obj.Placement = plm
|
obj.Placement = plm
|
||||||
|
@ -3724,6 +3731,8 @@ class _Circle(_DraftObject):
|
||||||
obj.addProperty("App::PropertyAngle","FirstAngle","Draft","Start angle of the arc")
|
obj.addProperty("App::PropertyAngle","FirstAngle","Draft","Start angle of the arc")
|
||||||
obj.addProperty("App::PropertyAngle","LastAngle","Draft","End angle of the arc (for a full circle, give it same value as First Angle)")
|
obj.addProperty("App::PropertyAngle","LastAngle","Draft","End angle of the arc (for a full circle, give it same value as First Angle)")
|
||||||
obj.addProperty("App::PropertyLength","Radius","Draft","Radius of the circle")
|
obj.addProperty("App::PropertyLength","Radius","Draft","Radius of the circle")
|
||||||
|
obj.addProperty("App::PropertyBool","MakeFace","Draft","Create a face")
|
||||||
|
obj.MakeFace = True
|
||||||
|
|
||||||
def execute(self, obj):
|
def execute(self, obj):
|
||||||
import Part
|
import Part
|
||||||
|
@ -3731,6 +3740,10 @@ class _Circle(_DraftObject):
|
||||||
shape = Part.makeCircle(obj.Radius.Value,Vector(0,0,0),Vector(0,0,1),obj.FirstAngle.Value,obj.LastAngle.Value)
|
shape = Part.makeCircle(obj.Radius.Value,Vector(0,0,0),Vector(0,0,1),obj.FirstAngle.Value,obj.LastAngle.Value)
|
||||||
if obj.FirstAngle.Value == obj.LastAngle.Value:
|
if obj.FirstAngle.Value == obj.LastAngle.Value:
|
||||||
shape = Part.Wire(shape)
|
shape = Part.Wire(shape)
|
||||||
|
if hasattr(obj,"MakeFace"):
|
||||||
|
if obj.MakeFace:
|
||||||
|
shape = Part.Face(shape)
|
||||||
|
else:
|
||||||
shape = Part.Face(shape)
|
shape = Part.Face(shape)
|
||||||
obj.Shape = shape
|
obj.Shape = shape
|
||||||
obj.Placement = plm
|
obj.Placement = plm
|
||||||
|
@ -3742,6 +3755,8 @@ class _Ellipse(_DraftObject):
|
||||||
_DraftObject.__init__(self,obj,"Ellipse")
|
_DraftObject.__init__(self,obj,"Ellipse")
|
||||||
obj.addProperty("App::PropertyLength","MinorRadius","Draft","The minor radius of the ellipse")
|
obj.addProperty("App::PropertyLength","MinorRadius","Draft","The minor radius of the ellipse")
|
||||||
obj.addProperty("App::PropertyLength","MajorRadius","Draft","The major radius of the ellipse")
|
obj.addProperty("App::PropertyLength","MajorRadius","Draft","The major radius of the ellipse")
|
||||||
|
obj.addProperty("App::PropertyBool","MakeFace","Draft","Create a face")
|
||||||
|
obj.MakeFace = True
|
||||||
|
|
||||||
def execute(self, obj):
|
def execute(self, obj):
|
||||||
import Part
|
import Part
|
||||||
|
@ -3752,6 +3767,10 @@ class _Ellipse(_DraftObject):
|
||||||
if obj.MajorRadius.Value and obj.MinorRadius.Value:
|
if obj.MajorRadius.Value and obj.MinorRadius.Value:
|
||||||
shape = Part.Ellipse(Vector(0,0,0),obj.MajorRadius.Value,obj.MinorRadius.Value).toShape()
|
shape = Part.Ellipse(Vector(0,0,0),obj.MajorRadius.Value,obj.MinorRadius.Value).toShape()
|
||||||
shape = Part.Wire(shape)
|
shape = Part.Wire(shape)
|
||||||
|
if hasattr(obj,"MakeFace"):
|
||||||
|
if obj.MakeFace:
|
||||||
|
shape = Part.Face(shape)
|
||||||
|
else:
|
||||||
shape = Part.Face(shape)
|
shape = Part.Face(shape)
|
||||||
obj.Shape = shape
|
obj.Shape = shape
|
||||||
obj.Placement = plm
|
obj.Placement = plm
|
||||||
|
@ -3769,6 +3788,8 @@ class _Wire(_DraftObject):
|
||||||
obj.addProperty("App::PropertyVector","End","Draft","The end point of this line")
|
obj.addProperty("App::PropertyVector","End","Draft","The end point of this line")
|
||||||
obj.addProperty("App::PropertyLength","FilletRadius","Draft","Radius to use to fillet the corners")
|
obj.addProperty("App::PropertyLength","FilletRadius","Draft","Radius to use to fillet the corners")
|
||||||
obj.addProperty("App::PropertyLength","ChamferSize","Draft","Size of the chamfer to give to the corners")
|
obj.addProperty("App::PropertyLength","ChamferSize","Draft","Size of the chamfer to give to the corners")
|
||||||
|
obj.addProperty("App::PropertyBool","MakeFace","Draft","Create a face if this object is closed")
|
||||||
|
obj.MakeFace = True
|
||||||
obj.Closed = False
|
obj.Closed = False
|
||||||
|
|
||||||
def execute(self, obj):
|
def execute(self, obj):
|
||||||
|
@ -3778,6 +3799,10 @@ class _Wire(_DraftObject):
|
||||||
if obj.Base.isDerivedFrom("Sketcher::SketchObject"):
|
if obj.Base.isDerivedFrom("Sketcher::SketchObject"):
|
||||||
shape = obj.Base.Shape.copy()
|
shape = obj.Base.Shape.copy()
|
||||||
if obj.Base.Shape.isClosed():
|
if obj.Base.Shape.isClosed():
|
||||||
|
if hasattr(obj,"MakeFace"):
|
||||||
|
if obj.MakeFace:
|
||||||
|
shape = Part.Face(shape)
|
||||||
|
else:
|
||||||
shape = Part.Face(shape)
|
shape = Part.Face(shape)
|
||||||
obj.Shape = shape
|
obj.Shape = shape
|
||||||
elif obj.Base and obj.Tool:
|
elif obj.Base and obj.Tool:
|
||||||
|
@ -3804,6 +3829,10 @@ class _Wire(_DraftObject):
|
||||||
if w:
|
if w:
|
||||||
shape = w
|
shape = w
|
||||||
try:
|
try:
|
||||||
|
if hasattr(obj,"MakeFace"):
|
||||||
|
if obj.MakeFace:
|
||||||
|
shape = Part.Face(shape)
|
||||||
|
else:
|
||||||
shape = Part.Face(shape)
|
shape = Part.Face(shape)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
@ -3915,6 +3944,8 @@ class _Polygon(_DraftObject):
|
||||||
obj.addProperty("App::PropertyEnumeration","DrawMode","Draft","How the polygon must be drawn from the control circle")
|
obj.addProperty("App::PropertyEnumeration","DrawMode","Draft","How the polygon must be drawn from the control circle")
|
||||||
obj.addProperty("App::PropertyLength","FilletRadius","Draft","Radius to use to fillet the corners")
|
obj.addProperty("App::PropertyLength","FilletRadius","Draft","Radius to use to fillet the corners")
|
||||||
obj.addProperty("App::PropertyLength","ChamferSize","Draft","Size of the chamfer to give to the corners")
|
obj.addProperty("App::PropertyLength","ChamferSize","Draft","Size of the chamfer to give to the corners")
|
||||||
|
obj.addProperty("App::PropertyBool","MakeFace","Draft","Create a face")
|
||||||
|
obj.MakeFace = True
|
||||||
obj.DrawMode = ['inscribed','circumscribed']
|
obj.DrawMode = ['inscribed','circumscribed']
|
||||||
obj.FacesNumber = 0
|
obj.FacesNumber = 0
|
||||||
obj.Radius = 1
|
obj.Radius = 1
|
||||||
|
@ -3944,6 +3975,10 @@ class _Polygon(_DraftObject):
|
||||||
w = DraftGeomUtils.filletWire(shape,obj.FilletRadius.Value)
|
w = DraftGeomUtils.filletWire(shape,obj.FilletRadius.Value)
|
||||||
if w:
|
if w:
|
||||||
shape = w
|
shape = w
|
||||||
|
if hasattr(obj,"MakeFace"):
|
||||||
|
if obj.MakeFace:
|
||||||
|
shape = Part.Face(shape)
|
||||||
|
else:
|
||||||
shape = Part.Face(shape)
|
shape = Part.Face(shape)
|
||||||
obj.Shape = shape
|
obj.Shape = shape
|
||||||
obj.Placement = plm
|
obj.Placement = plm
|
||||||
|
@ -4002,6 +4037,8 @@ class _BSpline(_DraftObject):
|
||||||
_DraftObject.__init__(self,obj,"BSpline")
|
_DraftObject.__init__(self,obj,"BSpline")
|
||||||
obj.addProperty("App::PropertyVectorList","Points","Draft", "The points of the b-spline")
|
obj.addProperty("App::PropertyVectorList","Points","Draft", "The points of the b-spline")
|
||||||
obj.addProperty("App::PropertyBool","Closed","Draft","If the b-spline is closed or not")
|
obj.addProperty("App::PropertyBool","Closed","Draft","If the b-spline is closed or not")
|
||||||
|
obj.addProperty("App::PropertyBool","MakeFace","Draft","Create a face if this spline is closed")
|
||||||
|
obj.MakeFace = True
|
||||||
obj.Closed = False
|
obj.Closed = False
|
||||||
obj.Points = []
|
obj.Points = []
|
||||||
|
|
||||||
|
@ -4021,6 +4058,10 @@ class _BSpline(_DraftObject):
|
||||||
# Creating a face from a closed spline cannot be expected to always work
|
# Creating a face from a closed spline cannot be expected to always work
|
||||||
# Usually, if the spline is not flat the call of Part.Face() fails
|
# Usually, if the spline is not flat the call of Part.Face() fails
|
||||||
try:
|
try:
|
||||||
|
if hasattr(obj,"MakeFace"):
|
||||||
|
if obj.MakeFace:
|
||||||
|
shape = Part.Face(shape)
|
||||||
|
else:
|
||||||
shape = Part.Face(shape)
|
shape = Part.Face(shape)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
@ -4047,6 +4088,8 @@ class _BezCurve(_DraftObject):
|
||||||
"Continuity")
|
"Continuity")
|
||||||
obj.addProperty("App::PropertyBool","Closed","Draft",
|
obj.addProperty("App::PropertyBool","Closed","Draft",
|
||||||
"If the Bezier curve should be closed or not")
|
"If the Bezier curve should be closed or not")
|
||||||
|
obj.addProperty("App::PropertyBool","MakeFace","Draft","Create a face if this curve is closed")
|
||||||
|
obj.MakeFace = True
|
||||||
obj.Closed = False
|
obj.Closed = False
|
||||||
obj.Degree = 3
|
obj.Degree = 3
|
||||||
obj.Continuity = []
|
obj.Continuity = []
|
||||||
|
@ -4106,6 +4149,10 @@ class _BezCurve(_DraftObject):
|
||||||
w = Part.Wire(edges)
|
w = Part.Wire(edges)
|
||||||
if fp.Closed and w.isClosed():
|
if fp.Closed and w.isClosed():
|
||||||
try:
|
try:
|
||||||
|
if hasattr(fp,"MakeFace"):
|
||||||
|
if fp.MakeFace:
|
||||||
|
w = Part.Face(w)
|
||||||
|
else:
|
||||||
w = Part.Face(w)
|
w = Part.Face(w)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>487</width>
|
<width>487</width>
|
||||||
<height>455</height>
|
<height>462</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -355,6 +355,26 @@ Values with differences below this value will be treated as same.</string>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
||||||
|
<item>
|
||||||
|
<widget class="Gui::PrefCheckBox" name="gui::prefcheckbox_6">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>If this is checked, objects will appear as filled as default. Otherwise, they will appear as wireframe</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Fill objects with faces whenever possible</string>
|
||||||
|
</property>
|
||||||
|
<property name="prefEntry" stdset="0">
|
||||||
|
<cstring>fillmode</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="prefPath" stdset="0">
|
||||||
|
<cstring>Mod/Draft</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -227,26 +227,6 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
|
||||||
<item>
|
|
||||||
<widget class="Gui::PrefCheckBox" name="gui::prefcheckbox_6">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>If this is checked, objects will appear as filled as default. Otherwise, they will appear as wireframe</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Fill objects by default</string>
|
|
||||||
</property>
|
|
||||||
<property name="prefEntry" stdset="0">
|
|
||||||
<cstring>fillmode</cstring>
|
|
||||||
</property>
|
|
||||||
<property name="prefPath" stdset="0">
|
|
||||||
<cstring>Mod/Draft</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
||||||
<item>
|
<item>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user