Skip to content

Commit

Permalink
Merge branch 'master' of ssh://git.code.sf.net/p/free-cad/code
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed May 8, 2014
2 parents 0467777 + 9cd2c75 commit d907d37
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 68 deletions.
87 changes: 67 additions & 20 deletions src/Mod/Draft/Draft.py
Expand Up @@ -573,6 +573,7 @@ def makeCircle(radius, placement=None, face=True, startangle=None, endangle=None
n = "Circle"
obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython",n)
_Circle(obj)
obj.MakeFace = face
if isinstance(radius,Part.Edge):
edge = radius
if DraftGeomUtils.geomType(edge) == "Circle":
Expand All @@ -598,7 +599,6 @@ def makeCircle(radius, placement=None, face=True, startangle=None, endangle=None
if placement: obj.Placement = placement
if gui:
_ViewProviderDraft(obj.ViewObject)
if not face: obj.ViewObject.DisplayMode = "Wireframe"
formatObject(obj)
select(obj)
FreeCAD.ActiveDocument.recompute()
Expand All @@ -616,10 +616,10 @@ def makeRectangle(length, height, placement=None, face=True, support=None):
obj.Length = length
obj.Height = height
obj.Support = support
obj.MakeFace = face
if placement: obj.Placement = placement
if gui:
_ViewProviderRectangle(obj.ViewObject)
if not face: obj.ViewObject.DisplayMode = "Wireframe"
formatObject(obj)
select(obj)
FreeCAD.ActiveDocument.recompute()
Expand Down Expand Up @@ -752,10 +752,10 @@ def makeWire(pointslist,closed=False,placement=None,face=True,support=None):
obj.Points = pointslist
obj.Closed = closed
obj.Support = support
obj.MakeFace = face
if placement: obj.Placement = placement
if gui:
_ViewProviderWire(obj.ViewObject)
if not face: obj.ViewObject.DisplayMode = "Wireframe"
formatObject(obj)
select(obj)
FreeCAD.ActiveDocument.recompute()
Expand All @@ -773,6 +773,7 @@ def makePolygon(nfaces,radius=1,inscribed=True,placement=None,face=True,support=
_Polygon(obj)
obj.FacesNumber = nfaces
obj.Radius = radius
obj.MakeFace = face
if inscribed:
obj.DrawMode = "inscribed"
else:
Expand All @@ -781,7 +782,6 @@ def makePolygon(nfaces,radius=1,inscribed=True,placement=None,face=True,support=
if placement: obj.Placement = placement
if gui:
_ViewProviderDraft(obj.ViewObject)
if not face: obj.ViewObject.DisplayMode = "Wireframe"
formatObject(obj)
select(obj)
FreeCAD.ActiveDocument.recompute()
Expand Down Expand Up @@ -824,16 +824,16 @@ def makeBSpline(pointslist,closed=False,placement=None,face=True,support=None):
obj.Closed = closed
obj.Points = pointslist
obj.Support = support
obj.MakeFace = face
if placement: obj.Placement = placement
if gui:
_ViewProviderWire(obj.ViewObject)
if not face: obj.ViewObject.DisplayMode = "Wireframe"
formatObject(obj)
select(obj)
FreeCAD.ActiveDocument.recompute()
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
from the given list of vectors. Instead of a pointslist, you can also pass a Part Wire.'''
if not isinstance(pointslist,list):
Expand All @@ -855,12 +855,13 @@ def makeBezCurve(pointslist,closed=False,placement=None,support=None,Degree=None
Part.BezierCurve().MaxDegree)
obj.Closed = closed
obj.Support = support
obj.MakeFace = face
obj.Proxy.resetcontinuity(obj)
if placement: obj.Placement = placement
if gui:
_ViewProviderWire(obj.ViewObject)
# if not face: obj.ViewObject.DisplayMode = "Wireframe"
obj.ViewObject.DisplayMode = "Wireframe"
# obj.ViewObject.DisplayMode = "Wireframe"
formatObject(obj)
select(obj)
FreeCAD.ActiveDocument.recompute()
Expand Down Expand Up @@ -3095,6 +3096,7 @@ def attach(self, vobj):

def updateData(self, obj, prop):
"called when the base object is changed"
import DraftGui
if prop in ["Start","End","Dimline","Direction"]:

if obj.Start == obj.End:
Expand Down Expand Up @@ -3199,10 +3201,9 @@ def updateData(self, obj, prop):
# set text value
l = self.p3.sub(self.p2).Length
if hasattr(obj.ViewObject,"Decimals"):
fstring = "%." + str(obj.ViewObject.Decimals) + "f"
self.string = DraftGui.displayExternal(l,obj.ViewObject.Decimals,'Length')
else:
fstring = "%." + str(getParam("dimPrecision",2)) + "f"
self.string = (fstring % l)
self.string = DraftGui.displayExternal(l,getParam("dimPrecision",2),'Length')
if hasattr(obj.ViewObject,"Override"):
if obj.ViewObject.Override:
try:
Expand Down Expand Up @@ -3684,6 +3685,8 @@ def __init__(self, obj):
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","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.Height=1

Expand All @@ -3706,7 +3709,11 @@ def execute(self, obj):
w = DraftGeomUtils.filletWire(shape,obj.FilletRadius.Value)
if w:
shape = w
shape = Part.Face(shape)
if hasattr(obj,"MakeFace"):
if obj.MakeFace:
shape = Part.Face(shape)
else:
shape = Part.Face(shape)
obj.Shape = shape
obj.Placement = plm

Expand All @@ -3724,14 +3731,20 @@ def __init__(self, obj):
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::PropertyLength","Radius","Draft","Radius of the circle")
obj.addProperty("App::PropertyBool","MakeFace","Draft","Create a face")
obj.MakeFace = True

def execute(self, obj):
import Part
plm = obj.Placement
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:
shape = Part.Wire(shape)
shape = Part.Face(shape)
if hasattr(obj,"MakeFace"):
if obj.MakeFace:
shape = Part.Face(shape)
else:
shape = Part.Face(shape)
obj.Shape = shape
obj.Placement = plm

Expand All @@ -3742,6 +3755,8 @@ def __init__(self, obj):
_DraftObject.__init__(self,obj,"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::PropertyBool","MakeFace","Draft","Create a face")
obj.MakeFace = True

def execute(self, obj):
import Part
Expand All @@ -3752,7 +3767,11 @@ def execute(self, obj):
if obj.MajorRadius.Value and obj.MinorRadius.Value:
shape = Part.Ellipse(Vector(0,0,0),obj.MajorRadius.Value,obj.MinorRadius.Value).toShape()
shape = Part.Wire(shape)
shape = Part.Face(shape)
if hasattr(obj,"MakeFace"):
if obj.MakeFace:
shape = Part.Face(shape)
else:
shape = Part.Face(shape)
obj.Shape = shape
obj.Placement = plm

Expand All @@ -3769,6 +3788,8 @@ def __init__(self, obj):
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","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

def execute(self, obj):
Expand All @@ -3778,7 +3799,11 @@ def execute(self, obj):
if obj.Base.isDerivedFrom("Sketcher::SketchObject"):
shape = obj.Base.Shape.copy()
if obj.Base.Shape.isClosed():
shape = Part.Face(shape)
if hasattr(obj,"MakeFace"):
if obj.MakeFace:
shape = Part.Face(shape)
else:
shape = Part.Face(shape)
obj.Shape = shape
elif obj.Base and obj.Tool:
if obj.Base.isDerivedFrom("Part::Feature") and obj.Tool.isDerivedFrom("Part::Feature"):
Expand All @@ -3804,7 +3829,11 @@ def execute(self, obj):
if w:
shape = w
try:
shape = Part.Face(shape)
if hasattr(obj,"MakeFace"):
if obj.MakeFace:
shape = Part.Face(shape)
else:
shape = Part.Face(shape)
except:
pass
else:
Expand Down Expand Up @@ -3915,6 +3944,8 @@ def __init__(self, obj):
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","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.FacesNumber = 0
obj.Radius = 1
Expand Down Expand Up @@ -3944,7 +3975,11 @@ def execute(self, obj):
w = DraftGeomUtils.filletWire(shape,obj.FilletRadius.Value)
if w:
shape = w
shape = Part.Face(shape)
if hasattr(obj,"MakeFace"):
if obj.MakeFace:
shape = Part.Face(shape)
else:
shape = Part.Face(shape)
obj.Shape = shape
obj.Placement = plm

Expand Down Expand Up @@ -4002,6 +4037,8 @@ def __init__(self, obj):
_DraftObject.__init__(self,obj,"BSpline")
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","MakeFace","Draft","Create a face if this spline is closed")
obj.MakeFace = True
obj.Closed = False
obj.Points = []

Expand All @@ -4021,7 +4058,11 @@ def execute(self, obj):
# 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
try:
shape = Part.Face(shape)
if hasattr(obj,"MakeFace"):
if obj.MakeFace:
shape = Part.Face(shape)
else:
shape = Part.Face(shape)
except:
pass
obj.Shape = shape
Expand All @@ -4047,6 +4088,8 @@ def __init__(self, obj):
"Continuity")
obj.addProperty("App::PropertyBool","Closed","Draft",
"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.Degree = 3
obj.Continuity = []
Expand Down Expand Up @@ -4106,7 +4149,11 @@ def createGeometry(self,fp):
w = Part.Wire(edges)
if fp.Closed and w.isClosed():
try:
w = Part.Face(w)
if hasattr(fp,"MakeFace"):
if fp.MakeFace:
w = Part.Face(w)
else:
w = Part.Face(w)
except:
pass
fp.Shape = w
Expand Down Expand Up @@ -4653,8 +4700,8 @@ def __init__(self, obj):
_DraftObject.__init__(self,obj,"ShapeString")
obj.addProperty("App::PropertyString","String","Draft","Text string")
obj.addProperty("App::PropertyFile","FontFile","Draft","Font file name")
obj.addProperty("App::PropertyFloat","Size","Draft","Height of text")
obj.addProperty("App::PropertyFloat","Tracking","Draft",
obj.addProperty("App::PropertyLength","Size","Draft","Height of text")
obj.addProperty("App::PropertyLength","Tracking","Draft",
"Inter-character spacing")

def execute(self, obj):
Expand Down

0 comments on commit d907d37

Please sign in to comment.