From d5d71906fc86f3426b4ca98d66164348ed0e6689 Mon Sep 17 00:00:00 2001 From: Alex Zastrow Date: Tue, 5 Mar 2024 08:44:20 +0100 Subject: [PATCH 1/5] Enable Add Motor operator for batch selection Previously a link had to be the active object for the operator to be enabled. Now a link has to be in the selection and the operator will be applied to all links in the selection --- phobos/blender/operators/editing.py | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/phobos/blender/operators/editing.py b/phobos/blender/operators/editing.py index 0695f7f5..24f72232 100644 --- a/phobos/blender/operators/editing.py +++ b/phobos/blender/operators/editing.py @@ -1859,26 +1859,8 @@ def poll(cls, context): Returns: """ - active_obj = ( - context.active_object - and context.active_object.phobostype == 'link' - and context.active_object.mode == 'OBJECT' - ) - - if not active_obj: - return False - # for obj in context.selected_objects: - # if obj.mode == 'OBJECT' and obj.phobostype == 'link': - # active_obj = obj - # context.view_layer.objects.active = obj - # break - # if not active_obj: - else: - active_obj = context.active_object - - joint_obj = 'joint/type' in active_obj and active_obj['joint/type'] != 'fixed' - return joint_obj + return len([o for o in context.selected_objects if o.phobostype == "link"]) > 0 def execute(self, context): """ From 5bffb2ba0035b23e42ad889ba3d697c93c0a96b5 Mon Sep 17 00:00:00 2001 From: Alex Zastrow Date: Wed, 6 Mar 2024 06:27:01 +0100 Subject: [PATCH 2/5] Apply Add Motor operator only to joints Add feedback --- phobos/blender/operators/editing.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/phobos/blender/operators/editing.py b/phobos/blender/operators/editing.py index 24f72232..36873e7b 100644 --- a/phobos/blender/operators/editing.py +++ b/phobos/blender/operators/editing.py @@ -1859,8 +1859,9 @@ def poll(cls, context): Returns: """ - - return len([o for o in context.selected_objects if o.phobostype == "link"]) > 0 + objects = [o for o in context.selected_objects if o.phobostype == "link" + and "joint/type" in o and o["joint/type"] != "fixed"] + return len(objects) > 0 def execute(self, context): """ @@ -1871,7 +1872,8 @@ def execute(self, context): Returns: """ - objects = [o for o in context.selected_objects if o.phobostype == "link"] + objects = [o for o in context.selected_objects if o.phobostype == "link" + and "joint/type" in o and o["joint/type"] != "fixed"] for obj in objects: phobos2blender.createMotor(representation.Motor( name=obj.name+"_motor", @@ -1882,6 +1884,9 @@ def execute(self, context): i=self.controli, d=self.controld ), linkobj=obj) + n = len(objects) + s = "" if n == 1 else "s" + log(message=f"Added a motor to {n} joint{s}", level="INFO") return {'FINISHED'} From cbd6bfe37f81fc916ea728a36522cda1ab05ba51 Mon Sep 17 00:00:00 2001 From: Alex Zastrow Date: Mon, 11 Mar 2024 15:12:24 +0100 Subject: [PATCH 3/5] Fix tooltip --- phobos/blender/operators/editing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phobos/blender/operators/editing.py b/phobos/blender/operators/editing.py index 36873e7b..ed657cd1 100644 --- a/phobos/blender/operators/editing.py +++ b/phobos/blender/operators/editing.py @@ -1758,7 +1758,7 @@ def poll(cls, context): class AddMotorOperator(Operator): """Add a motor to the selected joint. - It is possible to add motors to multiple joints at the same time""" +It is possible to add motors to multiple joints at the same time""" bl_idname = "phobos.add_motor" bl_label = "Add Motor" From ec783695dadd33806cba03d32804711cdafe16fd Mon Sep 17 00:00:00 2001 From: Alex Zastrow Date: Wed, 9 Oct 2024 14:45:35 +0200 Subject: [PATCH 4/5] Fix tooltip --- phobos/blender/operators/editing.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/phobos/blender/operators/editing.py b/phobos/blender/operators/editing.py index ed657cd1..2ca80117 100644 --- a/phobos/blender/operators/editing.py +++ b/phobos/blender/operators/editing.py @@ -1758,16 +1758,21 @@ def poll(cls, context): class AddMotorOperator(Operator): """Add a motor to the selected joint. -It is possible to add motors to multiple joints at the same time""" + It is possible to add motors to multiple joints at the same time""" bl_idname = "phobos.add_motor" bl_label = "Add Motor" bl_options = {'UNDO'} + bl_description = "Add a motor to the selected joint.\n" \ + "It is possible to add motors to multiple joints at the same time" lastMotorDefault = None - template : EnumProperty(items=[(n,n,n) for n in resources.get_motor_defaults()], name='Template', description="The template to use for this motor") - motorType : EnumProperty(items=[(n,n,n) for n in representation.Motor.BUILD_TYPES], name="Motor type", description='The motor type') - controllerType: EnumProperty(items=[(n,n,n) for n in representation.Motor.TYPES], name="Controller type", description='The controller type') + template : EnumProperty(items=[(n,n,n) for n in resources.get_motor_defaults()], name='Template', + description="The template to use for this motor") + motorType : EnumProperty(items=[(n,n,n) for n in representation.Motor.BUILD_TYPES], name="Motor type", + description='The motor type') + controllerType: EnumProperty(items=[(n,n,n) for n in representation.Motor.TYPES], name="Controller type", + description='The controller type') maxeffort : FloatProperty( name="Max Effort (N or Nm)", default=0.0, description="Maximum effort of the joint" ) From a270674335b030e755e2669599017a22276a1da3 Mon Sep 17 00:00:00 2001 From: Alex Zastrow Date: Thu, 14 Nov 2024 15:08:38 +0100 Subject: [PATCH 5/5] Fix Add Sensor tooltip --- phobos/blender/operators/editing.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/phobos/blender/operators/editing.py b/phobos/blender/operators/editing.py index 2ca80117..81560b35 100644 --- a/phobos/blender/operators/editing.py +++ b/phobos/blender/operators/editing.py @@ -2090,6 +2090,9 @@ class AddSensorOperator(Operator): bl_idname = "phobos.add_sensor" bl_label = "Add Sensor" bl_options = {'REGISTER', 'UNDO'} + bl_description = "Add a sensor at the position of the selected object. \n" \ + "It is possible to create a new link for the sensor on the fly. Otherwise, \n" \ + "the next link in the hierarchy will be used to parent the sensor to" def sensorlist(self, context):