From 035e863592c0de9dfa088ec26008677d1e0db6fb Mon Sep 17 00:00:00 2001 From: PaddleStroke Date: Thu, 7 Nov 2024 10:01:52 +0100 Subject: [PATCH] Assembly: Fix regressions of https://github.com/FreeCAD/FreeCAD/pull/16671 --- src/Mod/Assembly/CommandCreateView.py | 4 ++-- src/Mod/Assembly/JointObject.py | 2 +- src/Mod/Assembly/UtilsAssembly.py | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Mod/Assembly/CommandCreateView.py b/src/Mod/Assembly/CommandCreateView.py index b0343312bd..1712cba89a 100644 --- a/src/Mod/Assembly/CommandCreateView.py +++ b/src/Mod/Assembly/CommandCreateView.py @@ -526,9 +526,9 @@ class TaskAssemblyCreateView(QtCore.QObject): UtilsAssembly.restoreAssemblyPartsPlacements(self.assembly, self.initialPlcs) for move in self.viewObj.Moves: move.Visibility = False - commands = f'obj = App.ActiveDocument.getObject("{self.viewObj.Name}")\n' + commands = "" for move in self.viewObj.Moves: - more = UtilsAssembly.generatePropertySettings("obj.Moves[0]", move) + more = UtilsAssembly.generatePropertySettings(move) commands = commands + more Gui.doCommand(commands[:-1]) # Don't use the last \n App.closeActiveTransaction() diff --git a/src/Mod/Assembly/JointObject.py b/src/Mod/Assembly/JointObject.py index 1fc6f38591..b31a9588bd 100644 --- a/src/Mod/Assembly/JointObject.py +++ b/src/Mod/Assembly/JointObject.py @@ -1309,7 +1309,7 @@ class TaskAssemblyCreateJoint(QtCore.QObject): else: self.joint.Document.removeObject(self.joint.Name) - cmds = UtilsAssembly.generatePropertySettings("obj", self.joint) + cmds = UtilsAssembly.generatePropertySettings(self.joint) Gui.doCommand(cmds) App.closeActiveTransaction() diff --git a/src/Mod/Assembly/UtilsAssembly.py b/src/Mod/Assembly/UtilsAssembly.py index da07bf0eaf..0450b34995 100644 --- a/src/Mod/Assembly/UtilsAssembly.py +++ b/src/Mod/Assembly/UtilsAssembly.py @@ -1237,30 +1237,30 @@ def getParentPlacementIfNeeded(part): return Base.Placement() -def generatePropertySettings(objectName, documentObject): +def generatePropertySettings(documentObject): commands = [] if hasattr(documentObject, "Name"): - commands.append(f'{objectName} = App.ActiveDocument.getObject("{documentObject.Name}")') + commands.append(f'obj = App.ActiveDocument.getObject("{documentObject.Name}")') for propertyName in documentObject.PropertiesList: propertyValue = documentObject.getPropertyByName(propertyName) propertyType = documentObject.getTypeIdOfProperty(propertyName) # Note: OpenCascade precision is 1e-07, angular precision is 1e-05. For purposes of creating a Macro, # we are forcing a reduction in precision so as to get round numbers like 0 instead of tiny near 0 values if propertyType == "App::PropertyFloat": - commands.append(f"{objectName}.{propertyName} = {propertyValue:.5f}") + commands.append(f"obj.{propertyName} = {propertyValue:.5f}") elif propertyType == "App::PropertyInt" or propertyType == "App::PropertyBool": - commands.append(f"{objectName}.{propertyName} = {propertyValue}") + commands.append(f"obj.{propertyName} = {propertyValue}") elif propertyType == "App::PropertyString" or propertyType == "App::PropertyEnumeration": - commands.append(f'{objectName}.{propertyName} = "{propertyValue}"') + commands.append(f'obj.{propertyName} = "{propertyValue}"') elif propertyType == "App::PropertyPlacement": commands.append( - f"{objectName}.{propertyName} = App.Placement(" + f"obj.{propertyName} = App.Placement(" f"App.Vector({propertyValue.Base.x:.5f},{propertyValue.Base.y:.5f},{propertyValue.Base.z:.5f})," f"App.Rotation(*{[round(n,5) for n in propertyValue.Rotation.getYawPitchRoll()]}))" ) elif propertyType == "App::PropertyXLinkSubHidden": commands.append( - f'{objectName}.{propertyName} = [App.ActiveDocument.getObject("{propertyValue[0].Name}"), {propertyValue[1]}]' + f'obj.{propertyName} = [App.ActiveDocument.getObject("{propertyValue[0].Name}"), {propertyValue[1]}]' ) else: # print("Not processing properties of type ", propertyType)