Skip to content

Commit 4e37f7f

Browse files
authored
Merge pull request #352 from AlpenAalAlex/issue350-Define-Joint-dialog-remembers-and-applies-last-joint-name
Update Define Joint operator
2 parents b0d7dc9 + 6aa8c9c commit 4e37f7f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

phobos/blender/operators/editing.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -1507,6 +1507,8 @@ class DefineJointConstraintsOperator(Operator):
15071507
name="Joint Axis", default=[0.0, 0.0, 1], description="Damping constant of the joint", size=3
15081508
)
15091509

1510+
executeMessage = []
1511+
15101512
def draw(self, context):
15111513
"""
15121514
@@ -1517,6 +1519,8 @@ def draw(self, context):
15171519
15181520
"""
15191521
layout = self.layout
1522+
for msg in self.executeMessage:
1523+
layout.label(text=msg)
15201524
if self.name.replace(" ", "_") != self.name:
15211525
layout.label(text="Created as "+self.name.replace(" ", "_"))
15221526
if len(context.selected_objects) == 1:
@@ -1566,6 +1570,7 @@ def invoke(self, context, event):
15661570
15671571
"""
15681572
obj = context.active_object
1573+
self.name = ""
15691574
if any([k.startswith("joint") for k in obj.keys()]):
15701575
if "joint/limits/lower" in obj:
15711576
self.lower = obj["joint/limits/lower"]
@@ -1592,6 +1597,7 @@ def execute(self, context):
15921597
15931598
"""
15941599
log('Defining joint constraints for joint: ', 'INFO')
1600+
self.executeMessage = []
15951601
lower = 0
15961602
upper = 0
15971603
velocity = self.maxvelocity
@@ -1622,8 +1628,10 @@ def execute(self, context):
16221628
# Check if joints can be created
16231629
if max(axis) == 0 and min(axis) == 0:
16241630
validInput = False
1631+
self.executeMessage.append("Please set the joint axis to define the joint")
16251632
# set properties for each joint
16261633
if validInput:
1634+
defined = 0
16271635
for joint in (obj for obj in context.selected_objects if obj.phobostype == 'link'):
16281636
context.view_layer.objects.active = joint
16291637
if joint.parent is None or joint.parent.phobostype != "link":
@@ -1642,6 +1650,7 @@ def execute(self, context):
16421650
damping=self.damping,
16431651
axis=(np.array(axis) / np.linalg.norm(axis)).tolist() if axis is not None else None
16441652
)
1653+
defined = defined+1
16451654

16461655
if "joint/name" not in joint:
16471656
joint["joint/name"] = joint.name + "_joint"
@@ -1656,6 +1665,8 @@ def execute(self, context):
16561665
),
16571666
linkobj=joint
16581667
)
1668+
jointPluralS = "" if defined == 1 else "s"
1669+
self.executeMessage.append(f"Defined {defined} joint{jointPluralS}")
16591670

16601671
return {'FINISHED'}
16611672

@@ -3070,7 +3081,6 @@ def draw(self, context):
30703081
for t in self.executeMessage:
30713082
layout.label(text=t)
30723083

3073-
30743084
def execute(self, context):
30753085
"""
30763086

0 commit comments

Comments
 (0)