From b8e19824ec48128cb92914192759521c822013fa Mon Sep 17 00:00:00 2001 From: Alex Zastrow Date: Tue, 5 Mar 2024 07:33:50 +0100 Subject: [PATCH 1/3] Add feedback to Define Joint operator #324 --- phobos/blender/operators/editing.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/phobos/blender/operators/editing.py b/phobos/blender/operators/editing.py index 0695f7f5..8b73665b 100644 --- a/phobos/blender/operators/editing.py +++ b/phobos/blender/operators/editing.py @@ -1507,6 +1507,8 @@ class DefineJointConstraintsOperator(Operator): name="Joint Axis", default=[0.0, 0.0, 1], description="Damping constant of the joint", size=3 ) + executeMessage = [] + def draw(self, context): """ @@ -1555,6 +1557,9 @@ def draw(self, context): layout.prop(self, "spring", text="spring constant [N/m]") layout.prop(self, "damping", text="damping constant") + for msg in self.executeMessage: + layout.label(text=msg) + def invoke(self, context, event): """ @@ -1592,6 +1597,7 @@ def execute(self, context): """ log('Defining joint constraints for joint: ', 'INFO') + self.executeMessage = [] lower = 0 upper = 0 velocity = self.maxvelocity @@ -1622,8 +1628,10 @@ def execute(self, context): # Check if joints can be created if max(axis) == 0 and min(axis) == 0: validInput = False + self.executeMessage.append("Please set the joint axis to define the joint") # set properties for each joint if validInput: + defined = 0 for joint in (obj for obj in context.selected_objects if obj.phobostype == 'link'): context.view_layer.objects.active = joint if joint.parent is None or joint.parent.phobostype != "link": @@ -1642,6 +1650,7 @@ def execute(self, context): damping=self.damping, axis=(np.array(axis) / np.linalg.norm(axis)).tolist() if axis is not None else None ) + defined = defined+1 if "joint/name" not in joint: joint["joint/name"] = joint.name + "_joint" @@ -1656,6 +1665,8 @@ def execute(self, context): ), linkobj=joint ) + jointPluralS = "" if defined == 1 else "s" + self.executeMessage.append(f"Defined {defined} joint{jointPluralS}") return {'FINISHED'} From f0ae212f3b7aa2f9b55e146a296707f3f182c21d Mon Sep 17 00:00:00 2001 From: Alex Zastrow Date: Tue, 12 Mar 2024 15:20:22 +0100 Subject: [PATCH 2/3] Fix Define Joint remembers last joint's name #350 --- phobos/blender/operators/editing.py | 1 + 1 file changed, 1 insertion(+) diff --git a/phobos/blender/operators/editing.py b/phobos/blender/operators/editing.py index 8b73665b..802187ad 100644 --- a/phobos/blender/operators/editing.py +++ b/phobos/blender/operators/editing.py @@ -1571,6 +1571,7 @@ def invoke(self, context, event): """ obj = context.active_object + self.name = "" if any([k.startswith("joint") for k in obj.keys()]): if "joint/limits/lower" in obj: self.lower = obj["joint/limits/lower"] From 6aa8c9c58f990a4bd5d3b82de9b4c48a77d7ef2c Mon Sep 17 00:00:00 2001 From: Alex Zastrow Date: Tue, 12 Mar 2024 15:30:06 +0100 Subject: [PATCH 3/3] Move feedback to top --- phobos/blender/operators/editing.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/phobos/blender/operators/editing.py b/phobos/blender/operators/editing.py index 802187ad..e48766d4 100644 --- a/phobos/blender/operators/editing.py +++ b/phobos/blender/operators/editing.py @@ -1519,6 +1519,8 @@ def draw(self, context): """ layout = self.layout + for msg in self.executeMessage: + layout.label(text=msg) if self.name.replace(" ", "_") != self.name: layout.label(text="Created as "+self.name.replace(" ", "_")) if len(context.selected_objects) == 1: @@ -1557,9 +1559,6 @@ def draw(self, context): layout.prop(self, "spring", text="spring constant [N/m]") layout.prop(self, "damping", text="damping constant") - for msg in self.executeMessage: - layout.label(text=msg) - def invoke(self, context, event): """ @@ -3082,7 +3081,6 @@ def draw(self, context): for t in self.executeMessage: layout.label(text=t) - def execute(self, context): """