Draft: Fix messages for Draft_Fillet
There were still too many messages.
This commit is contained in:
@@ -47,40 +47,42 @@ DraftGeomUtils = lz.LazyLoader("DraftGeomUtils", globals(), "DraftGeomUtils")
|
||||
## \addtogroup draftmake
|
||||
# @{
|
||||
|
||||
def _extract_edges(objs):
|
||||
"""Extract the edges from the list of objects, Draft lines or Part.Edges.
|
||||
def _extract_edge(obj):
|
||||
"""Extract the edge from an object, Draft line or Part.Edge."""
|
||||
edge = None
|
||||
if hasattr(obj, "PropertiesList"):
|
||||
if "Proxy" in obj.PropertiesList:
|
||||
if hasattr(obj.Proxy, "Type"):
|
||||
if obj.Proxy.Type in ("Wire", "Fillet"):
|
||||
edge = obj.Shape.Edges[0]
|
||||
elif "Shape" in obj.PropertiesList:
|
||||
if obj.Shape.ShapeType in ("Wire", "Edge"):
|
||||
edge = obj.Shape
|
||||
elif hasattr(obj, "ShapeType"):
|
||||
if obj.ShapeType in "Edge":
|
||||
edge = obj
|
||||
return edge
|
||||
|
||||
Parameters
|
||||
----------
|
||||
objs: list of Draft Lines or Part.Edges
|
||||
The list of edges from which to create the fillet.
|
||||
"""
|
||||
o1, o2 = objs
|
||||
if hasattr(o1, "PropertiesList"):
|
||||
if "Proxy" in o1.PropertiesList:
|
||||
if hasattr(o1.Proxy, "Type"):
|
||||
if o1.Proxy.Type in ("Wire", "Fillet"):
|
||||
e1 = o1.Shape.Edges[0]
|
||||
elif "Shape" in o1.PropertiesList:
|
||||
if o1.Shape.ShapeType in ("Wire", "Edge"):
|
||||
e1 = o1.Shape
|
||||
elif hasattr(o1, "ShapeType"):
|
||||
if o1.ShapeType in "Edge":
|
||||
e1 = o1
|
||||
|
||||
if hasattr(o2, "PropertiesList"):
|
||||
if "Proxy" in o2.PropertiesList:
|
||||
if hasattr(o2.Proxy, "Type"):
|
||||
if o2.Proxy.Type in ("Wire", "Fillet"):
|
||||
e2 = o2.Shape.Edges[0]
|
||||
elif "Shape" in o2.PropertiesList:
|
||||
if o2.Shape.ShapeType in ("Wire", "Edge"):
|
||||
e2 = o2.Shape
|
||||
elif hasattr(o2, "ShapeType"):
|
||||
if o2.ShapeType in "Edge":
|
||||
e2 = o2
|
||||
def _preprocess(objs, radius, chamfer):
|
||||
"""Check the inputs and return the edges for the fillet."""
|
||||
if len(objs) != 2:
|
||||
_err(translate("draft", "Two objects are needed."))
|
||||
return None
|
||||
|
||||
return e1, e2
|
||||
edge1 = _extract_edge(objs[0])
|
||||
edge2 = _extract_edge(objs[1])
|
||||
|
||||
if edge1 is None or edge2 is None:
|
||||
_err(translate("draft", "One object is not valid."))
|
||||
return None
|
||||
|
||||
edges = DraftGeomUtils.fillet([edge1, edge2], radius, chamfer)
|
||||
if len(edges) < 3:
|
||||
_err(translate("draft", "Radius is too large") + ", r={}".format(radius))
|
||||
return None
|
||||
|
||||
return edges
|
||||
|
||||
|
||||
def make_fillet(objs, radius=100, chamfer=False, delete=False):
|
||||
@@ -110,26 +112,18 @@ def make_fillet(objs, radius=100, chamfer=False, delete=False):
|
||||
The object of Proxy type `'Fillet'`.
|
||||
It returns `None` if it fails producing the object.
|
||||
"""
|
||||
_name = "make_fillet"
|
||||
|
||||
if len(objs) != 2:
|
||||
_err(translate("draft","Two elements are needed."))
|
||||
return None
|
||||
|
||||
e1, e2 = _extract_edges(objs)
|
||||
|
||||
edges = DraftGeomUtils.fillet([e1, e2], radius, chamfer)
|
||||
if len(edges) < 3:
|
||||
_err(translate("draft","Radius is too large") + ", r={}".format(radius))
|
||||
return None
|
||||
edges = _preprocess(objs, radius, chamfer)
|
||||
if edges is None:
|
||||
return
|
||||
|
||||
try:
|
||||
wire = Part.Wire(edges)
|
||||
except Part.OCCError:
|
||||
return None
|
||||
|
||||
_doc = App.activeDocument()
|
||||
obj = _doc.addObject("Part::Part2DObjectPython", "Fillet")
|
||||
doc = App.activeDocument()
|
||||
obj = doc.addObject("Part::Part2DObjectPython", "Fillet")
|
||||
fillet.Fillet(obj)
|
||||
obj.Shape = wire
|
||||
obj.Length = wire.Length
|
||||
@@ -138,8 +132,8 @@ def make_fillet(objs, radius=100, chamfer=False, delete=False):
|
||||
obj.FilletRadius = radius
|
||||
|
||||
if delete:
|
||||
_doc.removeObject(objs[0].Name)
|
||||
_doc.removeObject(objs[1].Name)
|
||||
doc.removeObject(objs[0].Name)
|
||||
doc.removeObject(objs[1].Name)
|
||||
|
||||
if App.GuiUp:
|
||||
view_fillet.ViewProviderFillet(obj.ViewObject)
|
||||
|
||||
Reference in New Issue
Block a user