Skip to content

Commit

Permalink
Merge pull request FreeCAD#12230 from kpemartin/Issue11876
Browse files Browse the repository at this point in the history
Remove excessive output from Draft object creation and editing
  • Loading branch information
Roy-043 authored Feb 2, 2024
2 parents cfe13dc + 39bee92 commit ee3e1cd
Show file tree
Hide file tree
Showing 38 changed files with 65 additions and 292 deletions.
3 changes: 1 addition & 2 deletions src/Mod/Draft/DraftVecUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ def typecheck(args_and_types, name="?"):
"""
for v, t in args_and_types:
if not isinstance(v, t):
_msg = "typecheck[{0}]: {1} is not {2}".format(name, v, t)
messages._wrn(_msg)
messages._wrn("typecheck[{0}]: {1} is not {2}".format(name, v, t))
raise TypeError("fcvec." + str(name))


Expand Down
1 change: 0 additions & 1 deletion src/Mod/Draft/draftfunctions/downgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def downgrade(objects, delete=False, force=None):
upgrade
"""
_name = "downgrade"
utils.print_header(_name, "Downgrade objects")

if not isinstance(objects, list):
objects = [objects]
Expand Down
1 change: 0 additions & 1 deletion src/Mod/Draft/draftfunctions/mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def mirror(objlist, p1, p2):
just use `Part::Mirroring`. It should create a derived object,
that is, it should work similar to `Draft.offset`.
"""
utils.print_header('mirror', "Create mirror")

if not objlist:
_err(translate("draft","No object given"))
Expand Down
1 change: 0 additions & 1 deletion src/Mod/Draft/draftfunctions/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ def upgrade(objects, delete=False, force=None):
downgrade
"""
_name = "upgrade"
utils.print_header(_name, "Upgrade objects")

if not isinstance(objects, list):
objects = [objects]
Expand Down
2 changes: 0 additions & 2 deletions src/Mod/Draft/draftgeoutils/geo_arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,6 @@ def create_frames(obj, places):
len_wires = len(obj.Shape.Wires)
frames = list()
profiles = list()
# _msg("{}: {} wires".format(obj.Label, len_wires))
# _msg("places: {}".format(len(places)))

for i in places:
frame = obj.Shape.copy()
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Draft/draftguitools/gui_base_original.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from draftutils import params
from draftutils import todo
from draftutils import utils
from draftutils.messages import _log, _msg, _toolmsg
from draftutils.messages import _log, _toolmsg


class DraftTool:
Expand Down
8 changes: 3 additions & 5 deletions src/Mod/Draft/draftguitools/gui_edit_draft_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

from draftutils.translate import translate
import draftutils.utils as utils
from draftutils.messages import _msg
from draftutils.messages import _err

import draftguitools.gui_trackers as trackers

Expand Down Expand Up @@ -174,8 +174,7 @@ def add_point(self, edit_command, obj, pos):

def delete_point(self, obj, node_idx):
if len(obj.Points) <= 2:
_msg = translate("draft", "Active object must have more than two points/nodes")
App.Console.PrintWarning(_msg + "\n")
_err(translate("draft", "Active object must have more than two points/nodes"))
return

pts = obj.Points
Expand Down Expand Up @@ -837,8 +836,7 @@ def add_point(self, edit_command, obj, pos):

def delete_point(self, obj, node_idx):
if len(obj.Points) <= 2:
_msg = translate("draft", "Active object must have more than two points/nodes")
App.Console.PrintWarning(_msg + "\n")
_err(translate("draft", "Active object must have more than two points/nodes"))
return

pts = obj.Points
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Draft/draftguitools/gui_fillets.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import draftguitools.gui_base_original as gui_base_original
import draftguitools.gui_tool_utils as gui_tool_utils

from draftutils.messages import _msg, _err, _toolmsg
from draftutils.messages import _err, _toolmsg
from draftutils.translate import translate

# The module is used to prevent complaints from code checkers (flake8)
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Draft/draftguitools/gui_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from draftutils import params
from draftutils import utils
from draftutils import todo
from draftutils.messages import _err, _msg, _toolmsg
from draftutils.messages import _err, _toolmsg
from draftutils.translate import translate


Expand Down
1 change: 0 additions & 1 deletion src/Mod/Draft/draftguitools/gui_offset.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ def action(self, arg):
copymode = True
Gui.addModule("Draft")
if self.npts:
# _msg("offset:npts= " + str(self.npts))
_cmd = 'Draft.offset'
_cmd += '('
_cmd += 'FreeCAD.ActiveDocument.'
Expand Down
4 changes: 1 addition & 3 deletions src/Mod/Draft/draftguitools/gui_orthoarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import Draft_rc # include resources, icons, ui files
import draftutils.todo as todo

from draftutils.messages import _msg, _log
from draftutils.messages import _log
from draftutils.translate import translate
from draftguitools import gui_base
from drafttaskpanels import task_orthoarray
Expand Down Expand Up @@ -72,8 +72,6 @@ def Activated(self):
the widgets of the task panel.
"""
_log("GuiCommand: {}".format(self.command_name))
#_msg("{}".format(16*"-"))
#_msg("GuiCommand: {}".format(self.command_name))

# self.location = coin.SoLocation2Event.getClassTypeId()
self.mouse_event = coin.SoMouseButtonEvent.getClassTypeId()
Expand Down
4 changes: 1 addition & 3 deletions src/Mod/Draft/draftguitools/gui_polararray.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import Draft_rc # include resources, icons, ui files
import draftutils.todo as todo

from draftutils.messages import _msg, _log
from draftutils.messages import _log
from draftutils.translate import translate
from draftguitools import gui_base
from drafttaskpanels import task_polararray
Expand Down Expand Up @@ -72,8 +72,6 @@ def Activated(self):
the widgets of the task panel.
"""
_log("GuiCommand: {}".format(self.command_name))
#_msg("{}".format(16*"-"))
#_msg("GuiCommand: {}".format(self.command_name))

self.location = coin.SoLocation2Event.getClassTypeId()
self.mouse_event = coin.SoMouseButtonEvent.getClassTypeId()
Expand Down
6 changes: 3 additions & 3 deletions src/Mod/Draft/draftguitools/gui_trackers.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ def recompute(self):
except Exception:
# workaround for pivy SoInput.setBuffer() bug
buf = buf.replace("\n", "")
pts = re.findall("point \[(.*?)\]", buf)[0]
pts = re.findall("point \\[(.*?)\\]", buf)[0]
pts = pts.split(",")
pc = []
for p in pts:
Expand Down Expand Up @@ -523,7 +523,7 @@ def recompute(self):
except Exception:
# workaround for pivy SoInput.setBuffer() bug
buf = buf.replace("\n","")
pts = re.findall("point \[(.*?)\]", buf)[0]
pts = re.findall("point \\[(.*?)\\]", buf)[0]
pts = pts.split(",")
pc = []
for p in pts:
Expand Down Expand Up @@ -652,7 +652,7 @@ def recompute(self):
except Exception:
# workaround for pivy SoInput.setBuffer() bug
buf = buf.replace("\n", "")
pts = re.findall("point \[(.*?)\]", buf)[0]
pts = re.findall("point \\[(.*?)\\]", buf)[0]
pts = pts.split(",")
pc = []
for p in pts:
Expand Down
18 changes: 1 addition & 17 deletions src/Mod/Draft/draftmake/make_arc_3points.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import Part
import Draft
import draftutils.utils as utils
from draftutils.messages import _msg, _err
from draftutils.messages import _err
from draftutils.translate import translate

import draftutils.gui_utils as gui_utils
Expand Down Expand Up @@ -117,7 +117,6 @@ def make_arc_3points(points, placement=None, face=False,
Returns `None` if there is a problem and the object cannot be created.
"""
_name = "make_arc_3points"
utils.print_header(_name, "Arc by 3 points")

try:
utils.type_check([(points, (list, tuple))], name=_name)
Expand All @@ -141,10 +140,6 @@ def make_arc_3points(points, placement=None, face=False,

p1, p2, p3 = points

_msg("p1: {}".format(p1))
_msg("p2: {}".format(p2))
_msg("p3: {}".format(p3))

try:
utils.type_check([(p1, App.Vector),
(p2, App.Vector),
Expand All @@ -163,11 +158,7 @@ def make_arc_3points(points, placement=None, face=False,
radius = edge.Curve.Radius
center = edge.Curve.Center

_msg(translate("draft","Radius:") + " " + "{}".format(radius))
_msg(translate("draft","Center:") + " " + "{}".format(center))

if primitive:
_msg(translate("draft","Create primitive object"))
obj = App.ActiveDocument.addObject("Part::Feature", "Arc")
obj.Shape = edge
return obj
Expand All @@ -190,18 +181,11 @@ def make_arc_3points(points, placement=None, face=False,

if placement and not support:
obj.Placement.Base = placement.Base
_msg(translate("draft","Final placement:") + " " + "{}".format(obj.Placement))
if face:
_msg(translate("draft","Face: True"))
if support:
_msg(translate("draft","Support:") + " " + "{}".format(support))
_msg(translate("draft","Map mode:") + " " + "{}".format(map_mode))
obj.MapMode = map_mode
if placement:
obj.AttachmentOffset.Base = placement.Base
obj.AttachmentOffset.Rotation = original_placement.Rotation
_msg(translate("draft","Attachment offset: {}".format(obj.AttachmentOffset)))
_msg(translate("draft","Final placement:") + " " + "{}".format(obj.Placement))

return obj

Expand Down
18 changes: 2 additions & 16 deletions src/Mod/Draft/draftmake/make_circulararray.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import draftmake.make_array as make_array
import draftutils.utils as utils

from draftutils.messages import _msg, _err
from draftutils.messages import _err
from draftutils.translate import translate


Expand Down Expand Up @@ -119,23 +119,16 @@ def make_circular_array(base_object,
make_ortho_array, make_polar_array, make_path_array, make_point_array
"""
_name = "make_circular_array"
utils.print_header(_name, translate("draft","Circular array"))

if isinstance(base_object, str):
base_object_str = base_object

found, base_object = utils.find_object(base_object,
doc=App.activeDocument())
if not found:
_msg("base_object: {}".format(base_object_str))
_err(translate("draft","Wrong input: object not in document."))
_err(translate("draft","Wrong input: base_object {} not in document.").format(base_object_str))
return None

_msg("base_object: {}".format(base_object.Label))

_msg("r_distance: {}".format(r_distance))
_msg("tan_distance: {}".format(tan_distance))

try:
utils.type_check([(r_distance, (int, float, App.Units.Quantity)),
(tan_distance, (int, float, App.Units.Quantity))],
Expand All @@ -144,19 +137,13 @@ def make_circular_array(base_object,
_err(translate("draft","Wrong input: must be a number or quantity."))
return None

_msg("number: {}".format(number))
_msg("symmetry: {}".format(symmetry))

try:
utils.type_check([(number, int),
(symmetry, int)], name=_name)
except TypeError:
_err(translate("draft","Wrong input: must be an integer number."))
return None

_msg("axis: {}".format(axis))
_msg("center: {}".format(center))

try:
utils.type_check([(axis, App.Vector),
(center, App.Vector)], name=_name)
Expand All @@ -165,7 +152,6 @@ def make_circular_array(base_object,
return None

use_link = bool(use_link)
_msg("use_link: {}".format(use_link))

new_obj = make_array.make_array(base_object,
arg1=r_distance, arg2=tan_distance,
Expand Down
Loading

0 comments on commit ee3e1cd

Please sign in to comment.