Skip to content

Commit 779b48a

Browse files
committed
fix #53 better lock handling
1 parent 2f2c225 commit 779b48a

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

convert_Rotation_Mode/operators.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22
import bpy
33
from bpy.types import Operator
44
from bpy.types import Context
5-
from .utils import dprint, is_pose_mode, get_fcurves, toggle_rotation_locks, jump_next_frame
5+
from .utils import (
6+
dprint,
7+
is_pose_mode,
8+
get_fcurves,
9+
get_rotation_locks,
10+
toggle_rotation_locks,
11+
jump_next_frame,
12+
)
613

714

815
class CRM_OT_convert_rotation_mode(Operator):
@@ -53,13 +60,8 @@ def execute(self, context):
5360
f" # Target Rmode will be {CRM_Properties.targetRmode}"
5461
)
5562

56-
# self.locks = []
57-
self.locks.append(current_bone.lock_rotation[0])
58-
self.locks.append(current_bone.lock_rotation[1])
59-
self.locks.append(current_bone.lock_rotation[2])
60-
self.locks.append(current_bone.lock_rotation_w)
61-
self.locks.append(current_bone.lock_rotations_4d)
62-
toggle_rotation_locks('OFF', current_bone)
63+
locks = get_rotation_locks(current_bone)
64+
toggle_rotation_locks(current_bone, 'OFF')
6365
dprint(" | # Backed up and unlocked rotations")
6466

6567
original_rmode = current_bone.rotation_mode
@@ -128,7 +130,7 @@ def execute(self, context):
128130
break
129131

130132
if CRM_Properties.preserveLocks:
131-
toggle_rotation_locks('ON', current_bone)
133+
toggle_rotation_locks(current_bone, 'ON', locks)
132134
dprint(" | # Reverted rotation locks")
133135

134136
dprint(

convert_Rotation_Mode/utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ def get_fcurves(obj):
1818
return None
1919

2020

21+
def get_rotation_locks(bone):
22+
"""Return the current rotation lock state of the bone as a list."""
23+
return list(bone.lock_rotation) + [
24+
bone.lock_rotation_w,
25+
bone.lock_rotations_4d,
26+
]
27+
28+
2129
def jump_next_frame(context):
2230
"""Jump to the next frame in the timeline."""
2331
bpy.ops.screen.keyframe_jump(next=True)

0 commit comments

Comments
 (0)