From 5bbf59141ee09f690d300408f80bc16f5ffe9844 Mon Sep 17 00:00:00 2001 From: Roy Date: Fri, 11 Feb 2022 17:21:53 +0100 Subject: [PATCH] Draft: Housekeeping: call 'make' functions with new name, continued --- src/Mod/Draft/draftguitools/gui_clone.py | 2 +- src/Mod/Draft/draftguitools/gui_drawing.py | 4 ++-- src/Mod/Draft/draftguitools/gui_ellipses.py | 2 +- src/Mod/Draft/draftguitools/gui_facebinders.py | 2 +- src/Mod/Draft/draftguitools/gui_scale.py | 2 +- src/Mod/Draft/draftmake/make_clone.py | 16 ++++++++-------- src/Mod/Draft/draftmake/make_facebinder.py | 6 +++--- src/Mod/Draft/drafttests/test_modification.py | 2 +- src/Mod/Draft/draftutils/utils.py | 12 ++++++------ src/Mod/Draft/importDXF.py | 2 +- 10 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/Mod/Draft/draftguitools/gui_clone.py b/src/Mod/Draft/draftguitools/gui_clone.py index a061d81184..b59bdb12c3 100644 --- a/src/Mod/Draft/draftguitools/gui_clone.py +++ b/src/Mod/Draft/draftguitools/gui_clone.py @@ -93,7 +93,7 @@ class Clone(gui_base_original.Modifier): n = 0 for obj in Gui.Selection.getSelection(): if obj not in nonRepeatList: - _cmd = "Draft.clone" + _cmd = "Draft.make_clone" _cmd += "(" _cmd += "FreeCAD.ActiveDocument." _cmd += 'getObject("' + obj.Name + '")' diff --git a/src/Mod/Draft/draftguitools/gui_drawing.py b/src/Mod/Draft/draftguitools/gui_drawing.py index 49864823c4..107cd875d1 100644 --- a/src/Mod/Draft/draftguitools/gui_drawing.py +++ b/src/Mod/Draft/draftguitools/gui_drawing.py @@ -126,8 +126,8 @@ class Drawing(gui_base_original.Modifier): # oldobj = self.page.getObject(name) # if oldobj: # self.doc.removeObject(oldobj.Name) - Draft.makeDrawingView(obj, self.page, - otherProjection=otherProjection) + Draft.make_drawing_view(obj, self.page, + otherProjection=otherProjection) self.doc.recompute() def createDefaultPage(self): diff --git a/src/Mod/Draft/draftguitools/gui_ellipses.py b/src/Mod/Draft/draftguitools/gui_ellipses.py index 2c25e23f00..4a7611e41d 100644 --- a/src/Mod/Draft/draftguitools/gui_ellipses.py +++ b/src/Mod/Draft/draftguitools/gui_ellipses.py @@ -122,7 +122,7 @@ class Ellipse(gui_base_original.Creator): _cmd_list) else: # Insert a Draft ellipse - _cmd = 'Draft.makeEllipse' + _cmd = 'Draft.make_ellipse' _cmd += '(' _cmd += str(r1) + ', ' + str(r2) + ', ' _cmd += 'placement=pl, ' diff --git a/src/Mod/Draft/draftguitools/gui_facebinders.py b/src/Mod/Draft/draftguitools/gui_facebinders.py index e3fec1505b..beb1aeed78 100644 --- a/src/Mod/Draft/draftguitools/gui_facebinders.py +++ b/src/Mod/Draft/draftguitools/gui_facebinders.py @@ -81,7 +81,7 @@ class Facebinder(gui_base_original.Creator): App.ActiveDocument.openTransaction("Create Facebinder") Gui.addModule("Draft") Gui.doCommand("s = FreeCADGui.Selection.getSelectionEx()") - Gui.doCommand("facebinder = Draft.makeFacebinder(s)") + Gui.doCommand("facebinder = Draft.make_facebinder(s)") Gui.doCommand('Draft.autogroup(facebinder)') Gui.doCommand('FreeCAD.ActiveDocument.recompute()') App.ActiveDocument.commitTransaction() diff --git a/src/Mod/Draft/draftguitools/gui_scale.py b/src/Mod/Draft/draftguitools/gui_scale.py index 27c26b8e45..7bd08c68c9 100644 --- a/src/Mod/Draft/draftguitools/gui_scale.py +++ b/src/Mod/Draft/draftguitools/gui_scale.py @@ -237,7 +237,7 @@ class Scale(gui_base_original.Modifier): str_delta = DraftVecUtils.toString(self.delta) str_delta_corr = DraftVecUtils.toString(App.Vector(1,1,1) - self.delta) - _cmd = 'Draft.clone' + _cmd = 'Draft.make_clone' _cmd += '(' _cmd += objects + ', ' _cmd += 'forcedraft=True' diff --git a/src/Mod/Draft/draftmake/make_clone.py b/src/Mod/Draft/draftmake/make_clone.py index 4a4b57402f..05c17bc22c 100644 --- a/src/Mod/Draft/draftmake/make_clone.py +++ b/src/Mod/Draft/draftmake/make_clone.py @@ -40,22 +40,22 @@ if App.GuiUp: def make_clone(obj, delta=None, forcedraft=False): """clone(obj,[delta,forcedraft]) - - Makes a clone of the given object(s). + + Makes a clone of the given object(s). The clone is an exact, linked copy of the given object. If the original - object changes, the final object changes too. - + object changes, the final object changes too. + Parameters ---------- - obj : + obj : delta : Base.Vector - Delta Vector to move the clone from the original position. + Delta Vector to move the clone from the original position. forcedraft : bool If forcedraft is True, the resulting object is a Draft clone even if the input object is an Arch object. - + """ prefix = utils.get_param("ClonePrefix","") @@ -79,7 +79,7 @@ def make_clone(obj, delta=None, forcedraft=False): cl = Arch.makeComponent() else: try: - clonefunc = getattr(Arch,"make"+obj[0].Proxy.Type) + clonefunc = getattr(Arch, "make_" + obj[0].Proxy.Type.lower()) except Exception: pass # not a standard Arch object... Fall back to Draft mode else: diff --git a/src/Mod/Draft/draftmake/make_facebinder.py b/src/Mod/Draft/draftmake/make_facebinder.py index 7dcfa9db1e..da135e1d0c 100644 --- a/src/Mod/Draft/draftmake/make_facebinder.py +++ b/src/Mod/Draft/draftmake/make_facebinder.py @@ -37,10 +37,10 @@ if App.GuiUp: def make_facebinder(selectionset, name="Facebinder"): - """makeFacebinder(selectionset, [name]) - + """make_facebinder(selectionset, [name]) + Creates a Facebinder object from a selection set. - + Parameters ---------- selectionset : diff --git a/src/Mod/Draft/drafttests/test_modification.py b/src/Mod/Draft/drafttests/test_modification.py index 4d5d621fcc..f8c85a0d87 100644 --- a/src/Mod/Draft/drafttests/test_modification.py +++ b/src/Mod/Draft/drafttests/test_modification.py @@ -563,7 +563,7 @@ class DraftModification(unittest.TestCase): _msg(" Drawing view") _msg(" page={}".format(page.TypeId)) _msg(" template={}".format(page.Template)) - obj = Draft.makeDrawingView(prism, page, otherProjection=None) + obj = Draft.make_drawing_view(prism, page, otherProjection=None) self.assertTrue(obj, "'{}' failed".format(operation)) def test_mirror(self): diff --git a/src/Mod/Draft/draftutils/utils.py b/src/Mod/Draft/draftutils/utils.py index 11353dabc4..d85adadc8a 100644 --- a/src/Mod/Draft/draftutils/utils.py +++ b/src/Mod/Draft/draftutils/utils.py @@ -167,23 +167,23 @@ def get_param_type(param): "precision", "defaultWP", "snapRange", "gridEvery", "linewidth", "UiMode", "modconstrain", "modsnap", "maxSnapEdges", "modalt", "HatchPatternResolution", - "snapStyle", "dimstyle", "gridSize","gridTransparency"): + "snapStyle", "dimstyle", "gridSize", "gridTransparency"): return "int" elif param in ("constructiongroupname", "textfont", "patternFile", "template", "snapModes", - "FontFile", "ClonePrefix","overrideUnit", + "FontFile", "ClonePrefix", "overrideUnit", "labeltype") or "inCommandShortcut" in param: return "string" elif param in ("textheight", "tolerance", "gridSpacing", "arrowsize", "extlines", "dimspacing", - "dimovershoot", "extovershoot","HatchPatternSize"): + "dimovershoot", "extovershoot", "HatchPatternSize"): return "float" elif param in ("selectBaseObjects", "alwaysSnap", "grid", "fillmode", "saveonexit", "maxSnap", "SvgLinesBlack", "dxfStdSize", "showSnapBar", "hideSnapBar", "alwaysShowGrid", "renderPolylineWidth", "showPlaneTracker", "UsePartPrimitives", - "DiscretizeEllipses", "showUnit","coloredGridAxes", + "DiscretizeEllipses", "showUnit", "coloredGridAxes", "Draft_array_fuse", "Draft_array_Link", "gridBorder"): return "bool" elif param in ("color", "constructioncolor", @@ -509,14 +509,14 @@ def is_clone(obj, objtype=None, recursive=False): if `obj` is not even a clone. """ if isinstance(objtype, list): - return any([isClone(obj, t, recursive) for t in objtype]) + return any([is_clone(obj, t, recursive) for t in objtype]) if getType(obj) == "Clone": if len(obj.Objects) == 1: if objtype: if getType(obj.Objects[0]) == objtype: return True elif recursive and (getType(obj.Objects[0]) == "Clone"): - return isClone(obj.Objects[0], objtype, recursive) + return is_clone(obj.Objects[0], objtype, recursive) elif hasattr(obj, "CloneOf"): if obj.CloneOf: if objtype: diff --git a/src/Mod/Draft/importDXF.py b/src/Mod/Draft/importDXF.py index 409528963f..8d23a3f1fc 100644 --- a/src/Mod/Draft/importDXF.py +++ b/src/Mod/Draft/importDXF.py @@ -1815,7 +1815,7 @@ def drawInsert(insert, num=None, clone=False): addText(a, attrib=True) if clone: if insert.block in blockobjects: - newob = Draft.clone(blockobjects[insert.block]) + newob = Draft.make_clone(blockobjects[insert.block]) tsf = FreeCAD.Matrix() rot = math.radians(insert.rotation) pos = vec(insert.loc)