Skip to content

Commit

Permalink
Integrated geom save params - seed on/off works
Browse files Browse the repository at this point in the history
  • Loading branch information
ruaridhg committed Oct 6, 2023
1 parent 02ef8e8 commit 0f84b38
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 7 deletions.
72 changes: 70 additions & 2 deletions randomiser/random_all/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,15 @@ def execute(self, context):
_type_
_description_
"""

### ALL
if bpy.data.scenes["Scene"].seed_properties.seed_toggle: # = True
seed(bpy.data.scenes["Scene"].seed_properties.seed)
tot_frame_no = bpy.context.scene.rand_all_properties.tot_frame_no

### TRANSFORMS
bpy.data.scenes["Scene"].frame_current = 0
tot_frame_no = bpy.context.scene.rand_all_properties.tot_frame_no

x_pos_vals = []
y_pos_vals = []
z_pos_vals = []
Expand Down Expand Up @@ -179,6 +183,69 @@ def execute(self, context):
getattr(bpy.context.scene.camera, value_str)[2] * rad2deg
)

### GEOMETRY
bpy.data.scenes["Scene"].frame_current = 0

all_geom_dict = {}
cs = bpy.context.scene
for gng_idx in range(len(cs.socket_props_per_gng.collection)):
# get this subpanel's GNG
subpanel_gng = cs.socket_props_per_gng.collection[gng_idx]
tmp_GNG = subpanel_gng.name
print(tmp_GNG)

sockets_props_collection = cs.socket_props_per_gng.collection[
subpanel_gng.name
].collection

list_parent_nodes_str = [
sckt.name.split("_")[0] for sckt in sockets_props_collection
]
list_input_nodes = [
bpy.data.node_groups[subpanel_gng.name].nodes[nd_str]
for nd_str in list_parent_nodes_str
]

list_input_nodes_sorted = sorted(
list_input_nodes, key=lambda x: x.name
)
for i_n, nd in enumerate(list_input_nodes_sorted):
# add sockets for this node in the subseq rows
for sckt in nd.outputs:
print("i_n", i_n)
print("nd", nd)
print(
getattr(
sckt,
"default_value",
)
)

tmp_values = []
for idx in range(tot_frame_no):
bpy.app.handlers.frame_change_pre[0]("dummy")
bpy.data.scenes["Scene"].frame_current = idx
bpy.ops.node.randomise_all_geometry_sockets(
"INVOKE_DEFAULT"
) # issue
# w/ this being called so often -
# might need moved to diff for loop?
tmp_values.append(
getattr(
sckt,
"default_value",
)
)

print(tmp_values)
tmp_sck = nd.name
all_geom_dict[tmp_GNG] = tmp_sck
GNG_sck_values_str = tmp_GNG + tmp_sck
GNG_sck_values_str = "Values " + GNG_sck_values_str
print(GNG_sck_values_str)
all_geom_dict[GNG_sck_values_str] = tmp_values

print(all_geom_dict)
data = {
"location_str": loc_value_str,
"loc_x": x_pos_vals,
Expand All @@ -188,9 +255,10 @@ def execute(self, context):
"rot_x": x_rot_vals,
"rot_y": y_rot_vals,
"rot_z": z_rot_vals,
"geometry": all_geom_dict,
}

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

with open(path_to_file, "w") as out_file_obj:
# convert the dictionary into text
Expand Down
6 changes: 1 addition & 5 deletions randomiser/save_parameter_outputs_geom_test_in_Blender.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,9 @@
# bpy.data.scenes['Scene'].socket_props_per_material.collection[0].collection[1].max_rgba_4d[0-3]


# Min-max Geom values

### ALL
if bpy.data.scenes["Scene"].seed_properties.seed_toggle: # = True
seed(bpy.data.scenes["Scene"].seed_properties.seed)


### ALL
tot_frame_no = bpy.context.scene.rand_all_properties.tot_frame_no

### TRANSFORMS
Expand Down

0 comments on commit 0f84b38

Please sign in to comment.