Skip to content

Commit

Permalink
Save param button for transforms added
Browse files Browse the repository at this point in the history
  • Loading branch information
ruaridhg committed Sep 19, 2023
1 parent 5fc4ffd commit 85ba3f7
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
57 changes: 55 additions & 2 deletions randomiser/random_all/operators.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import json
import pathlib
from random import seed

import bpy
from bpy.app.handlers import persistent

Expand Down Expand Up @@ -129,8 +133,57 @@ def execute(self, context):
_type_
_description_
"""

print("hello")
bpy.data.scenes["Scene"].seed_properties.seed_toggle = True
seed(bpy.data.scenes["Scene"].seed_properties.seed)
bpy.data.scenes["Scene"].frame_current = 0
tot_frame_no = context.scene.rand_all_properties.tot_frame_no
x_pos_vals = []
y_pos_vals = []
z_pos_vals = []
# if context.scene.randomise_camera_props.bool_delta:
# value_str = "delta_location"
# else:
# value_str = "location"

x_rot_vals = []
y_rot_vals = []
z_rot_vals = []
# if context.scene.randomise_camera_props.bool_delta:
# value_str = "delta_rotation_euler"
# else:
# value_str = "rotation_euler"
# first_run.append(bpy.data.objects["Camera"].location[0])

for idx in range(tot_frame_no):
bpy.app.handlers.frame_change_pre[0]("dummy")
bpy.data.scenes["Scene"].frame_current = idx

x_pos_vals.append(bpy.data.objects["Camera"].location[0])
y_pos_vals.append(bpy.data.objects["Camera"].location[1])
z_pos_vals.append(bpy.data.objects["Camera"].location[2])

x_rot_vals.append(bpy.data.objects["Camera"].rotation_euler[0])
y_rot_vals.append(bpy.data.objects["Camera"].rotation_euler[1])
z_rot_vals.append(bpy.data.objects["Camera"].rotation_euler[2])

data = {
"transform_x": x_pos_vals,
"transform_y": y_pos_vals,
"transform_z": z_pos_vals,
"rotation_x": x_rot_vals,
"rotation_y": y_rot_vals,
"rotation_z": z_rot_vals,
}

print(data)
path_to_file = pathlib.Path.home() / "tmp" / "transform_test.json"
print(path_to_file)

with open(path_to_file, "w") as out_file_obj:
# convert the dictionary into text
text = json.dumps(data, indent=4)
# write the text into the file
out_file_obj.write(text)

return {"FINISHED"}

Expand Down
2 changes: 2 additions & 0 deletions randomiser/random_all/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class PropertiesRandomAll(bpy.types.PropertyGroup):
)
tot_frame_no: tot_frame_no_prop # type: ignore

# x_pos = bpy.props.GenericType()


# ------------------------------------
# Register / unregister classes
Expand Down

0 comments on commit 85ba3f7

Please sign in to comment.