Draft: Fix messages for Draft_Fillet
There were still too many messages.
This commit is contained in:
@@ -43,6 +43,7 @@ import draftutils.utils as utils
|
||||
import draftguitools.gui_base_original as gui_base_original
|
||||
import draftguitools.gui_tool_utils as gui_tool_utils
|
||||
|
||||
from draftmake import make_fillet
|
||||
from draftutils.messages import _err, _toolmsg
|
||||
from draftutils.translate import translate
|
||||
|
||||
@@ -104,7 +105,7 @@ class Fillet(gui_base_original.Creator):
|
||||
# self.linetrack = trackers.lineTracker(dotted=True)
|
||||
# self.arctrack = trackers.arcTracker()
|
||||
# self.call = self.view.addEventCallback("SoEvent", self.action)
|
||||
_toolmsg(translate("draft","Enter radius."))
|
||||
_toolmsg(translate("draft", "Enter radius."))
|
||||
|
||||
def action(self, arg):
|
||||
"""Scene event handler. CURRENTLY NOT USED.
|
||||
@@ -123,12 +124,10 @@ class Fillet(gui_base_original.Creator):
|
||||
def set_delete(self):
|
||||
"""Execute as a callback when the delete checkbox changes."""
|
||||
self.delete = self.ui.check_delete.isChecked()
|
||||
_toolmsg(translate("draft","Delete original objects:") + " " + str(self.delete))
|
||||
|
||||
def set_chamfer(self):
|
||||
"""Execute as a callback when the chamfer checkbox changes."""
|
||||
self.chamfer = self.ui.check_chamfer.isChecked()
|
||||
_toolmsg(translate("draft","Chamfer mode:") + " " + str(self.chamfer))
|
||||
|
||||
def numericRadius(self, rad):
|
||||
"""Validate the entry radius in the user interface.
|
||||
@@ -141,39 +140,24 @@ class Fillet(gui_base_original.Creator):
|
||||
|
||||
def draw_arc(self, rad, chamfer, delete):
|
||||
"""Process the selection and draw the actual object."""
|
||||
wires = Gui.Selection.getSelection()
|
||||
|
||||
if not wires or len(wires) != 2:
|
||||
_err(translate("draft","Two elements needed."))
|
||||
objs = Gui.Selection.getSelection()
|
||||
edges = make_fillet._preprocess(objs, rad, chamfer)
|
||||
if edges is None:
|
||||
_err(translate("draft", "Fillet cannot be created"))
|
||||
return
|
||||
|
||||
for o in wires:
|
||||
_toolmsg(utils.get_type(o))
|
||||
|
||||
_test = translate("draft", "Test object")
|
||||
_test_off = translate("draft", "Test object removed")
|
||||
_cant = translate("draft", "Fillet cannot be created")
|
||||
|
||||
_toolmsg(4*"=" + _test)
|
||||
arc = Draft.make_fillet(wires, rad)
|
||||
if not arc:
|
||||
_err(_cant)
|
||||
return
|
||||
self.doc.removeObject(arc.Name)
|
||||
_toolmsg(4*"=" + _test_off)
|
||||
|
||||
_doc = 'FreeCAD.ActiveDocument.'
|
||||
|
||||
_wires = '['
|
||||
_wires += _doc + wires[0].Name + ', '
|
||||
_wires += _doc + wires[1].Name
|
||||
_wires += ']'
|
||||
_objs = '['
|
||||
_objs += _doc + objs[0].Name + ', '
|
||||
_objs += _doc + objs[1].Name
|
||||
_objs += ']'
|
||||
|
||||
Gui.addModule("Draft")
|
||||
|
||||
_cmd = 'Draft.make_fillet'
|
||||
_cmd += '('
|
||||
_cmd += _wires + ', '
|
||||
_cmd += _objs + ', '
|
||||
_cmd += 'radius=' + str(rad)
|
||||
if chamfer:
|
||||
_cmd += ', chamfer=' + str(chamfer)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -30,8 +30,6 @@ from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
import FreeCAD as App
|
||||
import draftobjects.base as base
|
||||
|
||||
from draftutils.messages import _err
|
||||
|
||||
|
||||
class Fillet(base.DraftObject):
|
||||
"""Proxy class for the Fillet object."""
|
||||
@@ -113,7 +111,7 @@ class Fillet(base.DraftObject):
|
||||
#if (hasattr(obj, "Line1") and hasattr(obj, "Line2")
|
||||
# and obj.Line1 and obj.Line2):
|
||||
# do the unimplemented work
|
||||
_err("Update radius currently not implemented: r={}".format(radius))
|
||||
pass
|
||||
|
||||
def onChanged(self, obj, prop):
|
||||
"""Change the radius of fillet. NOT IMPLEMENTED.
|
||||
|
||||
Reference in New Issue
Block a user