@@ -1507,6 +1507,8 @@ class DefineJointConstraintsOperator(Operator):
1507
1507
name = "Joint Axis" , default = [0.0 , 0.0 , 1 ], description = "Damping constant of the joint" , size = 3
1508
1508
)
1509
1509
1510
+ executeMessage = []
1511
+
1510
1512
def draw (self , context ):
1511
1513
"""
1512
1514
@@ -1517,6 +1519,8 @@ def draw(self, context):
1517
1519
1518
1520
"""
1519
1521
layout = self .layout
1522
+ for msg in self .executeMessage :
1523
+ layout .label (text = msg )
1520
1524
if self .name .replace (" " , "_" ) != self .name :
1521
1525
layout .label (text = "Created as " + self .name .replace (" " , "_" ))
1522
1526
if len (context .selected_objects ) == 1 :
@@ -1566,6 +1570,7 @@ def invoke(self, context, event):
1566
1570
1567
1571
"""
1568
1572
obj = context .active_object
1573
+ self .name = ""
1569
1574
if any ([k .startswith ("joint" ) for k in obj .keys ()]):
1570
1575
if "joint/limits/lower" in obj :
1571
1576
self .lower = obj ["joint/limits/lower" ]
@@ -1592,6 +1597,7 @@ def execute(self, context):
1592
1597
1593
1598
"""
1594
1599
log ('Defining joint constraints for joint: ' , 'INFO' )
1600
+ self .executeMessage = []
1595
1601
lower = 0
1596
1602
upper = 0
1597
1603
velocity = self .maxvelocity
@@ -1622,8 +1628,10 @@ def execute(self, context):
1622
1628
# Check if joints can be created
1623
1629
if max (axis ) == 0 and min (axis ) == 0 :
1624
1630
validInput = False
1631
+ self .executeMessage .append ("Please set the joint axis to define the joint" )
1625
1632
# set properties for each joint
1626
1633
if validInput :
1634
+ defined = 0
1627
1635
for joint in (obj for obj in context .selected_objects if obj .phobostype == 'link' ):
1628
1636
context .view_layer .objects .active = joint
1629
1637
if joint .parent is None or joint .parent .phobostype != "link" :
@@ -1642,6 +1650,7 @@ def execute(self, context):
1642
1650
damping = self .damping ,
1643
1651
axis = (np .array (axis ) / np .linalg .norm (axis )).tolist () if axis is not None else None
1644
1652
)
1653
+ defined = defined + 1
1645
1654
1646
1655
if "joint/name" not in joint :
1647
1656
joint ["joint/name" ] = joint .name + "_joint"
@@ -1656,6 +1665,8 @@ def execute(self, context):
1656
1665
),
1657
1666
linkobj = joint
1658
1667
)
1668
+ jointPluralS = "" if defined == 1 else "s"
1669
+ self .executeMessage .append (f"Defined { defined } joint{ jointPluralS } " )
1659
1670
1660
1671
return {'FINISHED' }
1661
1672
@@ -3070,7 +3081,6 @@ def draw(self, context):
3070
3081
for t in self .executeMessage :
3071
3082
layout .label (text = t )
3072
3083
3073
-
3074
3084
def execute (self , context ):
3075
3085
"""
3076
3086
0 commit comments