forked from ArtemKirsanov/BlenderSpike
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathanimation_manager.py
42 lines (35 loc) · 1.62 KB
/
animation_manager.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import bpy
from .neuron_builder import BlenderNeuron
class BLENDERSPIKY_OT_HandlerRemover(bpy.types.Operator):
'''
Operator to clear frame_change_post handers.
Note: this should remove a handler linked to a selected object, but I don't know how to implement this.
So, as a temporary band aid, it just removes all handlers.
'''
bl_idname = 'blenderspiky.remove_handlers'
bl_label = 'Remove all voltage handlers'
def execute(self, context):
bpy.app.handlers.frame_change_post.clear()
return {"FINISHED"}
class BLENDERSPIKY_OT_AnimationLoader(bpy.types.Operator):
'''Reload animation data for selected neurons'''
bl_idname = 'blenderspiky.reload_animations'
bl_label = 'Reload animation data'
def execute(self, context):
'''
The operator reinstantiates BlenderNeuron and nested BlenderSection objects from the metadata of selected object
'''
for ob in context.selected_objects:
neuron = BlenderNeuron(
filepath=ob["filepath"],
with_caps=bool(ob["with_caps"]),
simplify_soma=bool(ob["simplify_soma"]),
segmentation=ob["segmentation"],
parent_ob=ob,
DOWNSCALE_FACTOR=ob["DOWNSCALE_FACTOR"],
branch_base_thickness=ob["branch_base_thickness"],
branch_thickness_homogeneity = ob["branch_thickness_homogeneity"]
)
neuron.reinstantiate_sections_from_childen()
neuron.add_voltage_handler()
return {"FINISHED"}