Draft: clean up CircularArray code

Avoid `Draft.py` in the `make_circular_array` function because
it creates a circular dependency.

Use function to find the object in `make_circular_array`.

Now the make function accepts as input a `"String"` which must be
the `Label` of an object in the document, so it is easier to create
arrays interactively from the Python console.

Clean up the GuiCommand and task panel code, and avoid printing
messages to the terminal, as this is already done
by the make function.
This commit is contained in:
vocx-fc
2020-05-24 21:28:58 -05:00
committed by Yorik van Havre
parent 33d3fb1fa9
commit 66959b2688
3 changed files with 60 additions and 35 deletions

View File

@@ -33,9 +33,10 @@ import FreeCADGui as Gui
import Draft_rc # include resources, icons, ui files
import DraftVecUtils
import draftutils.utils as utils
from FreeCAD import Units as U
from draftutils.messages import _msg, _wrn, _err, _log
from draftutils.translate import _tr
from FreeCAD import Units as U
# The module is used to prevent complaints from code checkers (flake8)
bool(Draft_rc.__name__)
@@ -198,7 +199,8 @@ class TaskPanelCircularArray:
self.center)
if self.valid_input:
self.create_object()
self.print_messages()
# The internal function already displays messages
# self.print_messages()
self.finish()
def validate_input(self, selection,
@@ -266,15 +268,13 @@ class TaskPanelCircularArray:
sel_obj = self.selection[0]
# This creates the object immediately
# obj = Draft.makeArray(sel_obj,
# self.r_distance, self.tan_distance,
# self.axis, self.center,
# self.number, self.symmetry,
# self.use_link)
# if obj:
# obj.Fuse = self.fuse
# obj = Draft.make_circular_array(sel_obj,
# self.r_distance, self.tan_distance,
# self.number, self.symmetry,
# self.axis, self.center,
# self.use_link)
# Instead, we build the commands to execute through the parent
# Instead, we build the commands to execute through the caller
# of this class, the GuiCommand.
# This is needed to schedule geometry manipulation
# that would crash Coin3D if done in the event callback.