Skip to content

Commit dfc1c49

Browse files
committed
remove need for active armature
1 parent 1f55d77 commit dfc1c49

File tree

14 files changed

+25
-28
lines changed

14 files changed

+25
-28
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ When thinking of animatronic or robotic projects, you could animate a head or ar
6666

6767
Once all servo settings are provided and your animation is ready, you can calculate and export the servo position values.
6868

69-
Make sure to select the armature containing the bones/servos you want to export and choose the desired format in the `File > Export` menu:
69+
Choose the desired format in the `File > Export` menu:
7070

7171
![Export Menu Top](images/export_menu.png)
7272

addon/ops/arduino_export.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class ArduinoExport(Operator, BaseExport, ExportHelper):
99
bl_idname = "export_anim.servo_animation_arduino"
1010
bl_label = "Servo Animation (.h)"
11-
bl_description = "Save an Arduino header file with servo position values of the active armature"
11+
bl_description = "Save an Arduino header file with servo position values of the active scene"
1212

1313
filename_ext = ".h"
1414
chunk_size = 12
@@ -32,10 +32,14 @@ def export(self, positions, filepath, context):
3232
filename = self.get_blend_filename()
3333

3434
content = (
35-
"/*\n Blender Servo Animation Positions\n\n "
36-
f"FPS: {fps}\n Frames: {frames}\n Seconds: {seconds}\n "
37-
f"Bones: {len(positions[0])}\n Armature: {context.object.name}\n "
38-
f"Scene: {context.scene.name}\n File: {filename}\n*/\n\n"
35+
"/*\n Blender Servo Animation Positions\n\n"
36+
f" FPS: {fps}\n"
37+
f" Frames: {frames}\n"
38+
f" Seconds: {seconds}\n"
39+
f" Bones: {len(positions[0])}\n"
40+
f" Scene: {context.scene.name}\n"
41+
f" File: {filename}\n"
42+
"*/\n\n"
3943
"#include <Arduino.h>\n"
4044
)
4145

addon/ops/base_export.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from ..utils.converter import calculate_positions
55
from ..utils.live_mode import LiveMode
6+
from ..utils.servo_settings import get_active_pose_bones
67

78

89
class BaseExport:
@@ -18,11 +19,12 @@ class BaseExport:
1819

1920
@classmethod
2021
def poll(cls, context):
21-
if not context.object or context.object.type != 'ARMATURE':
22-
return False
23-
for pose_bone in context.object.pose.bones:
22+
pose_bones = get_active_pose_bones(context.scene)
23+
24+
for pose_bone in pose_bones:
2425
if pose_bone.bone.servo_settings.active:
2526
return True
27+
2628
return False
2729

2830
def execute(self, context):

addon/ops/binary_export.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class BinaryExport(Operator, BaseExport, ExportHelper):
99
bl_idname = "export_anim.servo_animation_binary"
1010
bl_label = "Servo Animation (.bin)"
11-
bl_description = "Save a binary file with servo position values of the active armature"
11+
bl_description = "Save a binary file with servo position values of the active scene"
1212

1313
filename_ext = ".bin"
1414

addon/ops/json_export.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
class JsonExport(Operator, BaseExport, ExportHelper):
1010
bl_idname = "export_anim.servo_animation_json"
1111
bl_label = "Servo Animation (.json)"
12-
bl_description = "Save a JSON file with servo position values of the active armature"
12+
bl_description = "Save a JSON file with servo position values of the active scene"
1313

1414
filename_ext = ".json"
1515

@@ -46,7 +46,6 @@ def export(self, positions, filepath, context):
4646
"frames": frames,
4747
"seconds": seconds,
4848
"bones": len(positions[0]),
49-
"armature": context.object.name,
5049
"file": filename,
5150
"scene": context.scene.name,
5251
"positions": positions

examples/IK/ik.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
Frames: 100
66
Seconds: 3
77
Bones: 2
8-
Armature: Armature
98
Scene: Scene
109
File: ik.blend
1110
*/

examples/IK/ik.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"frames": 100,
55
"seconds": 3,
66
"bones": 2,
7-
"armature": "Armature",
87
"file": "ik.blend",
98
"scene": "Scene",
109
"positions": [

examples/Scenes/scene-a.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
Frames: 100
66
Seconds: 3
77
Bones: 1
8-
Armature: Armature
98
Scene: SceneA
109
File: scenes.blend
1110
*/

examples/Scenes/scene-a.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"frames": 100,
55
"seconds": 3,
66
"bones": 1,
7-
"armature": "Armature",
87
"file": "scenes.blend",
98
"scene": "SceneA",
109
"positions": [

examples/Scenes/scene-b.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
Frames: 200
66
Seconds: 3
77
Bones: 1
8-
Armature: Armature.001
98
Scene: SceneB
109
File: scenes.blend
1110
*/

0 commit comments

Comments
 (0)