Skip to content

Commit

Permalink
Define_props bool randomise working
Browse files Browse the repository at this point in the history
  • Loading branch information
ruaridhg committed Oct 4, 2023
1 parent f9605ec commit b420f6d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 27 deletions.
9 changes: 5 additions & 4 deletions randomiser/define_prop/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ def invoke(self, context, event):
]
# for every GNG: save sockets to randomise
self.sockets_to_randomise_per_UD = {}
self.sockets_to_randomise_per_UD = []
for UD_str in self.list_subpanel_UD_props_names:
# if cs.socket_props_per_UD.collection[
# UD_str
Expand Down Expand Up @@ -286,10 +287,9 @@ def invoke(self, context, event):
# "randomisation toggle set to False",
# )

self.sockets_to_randomise_per_UD[UD_str] = []
sckt = cs.socket_props_per_UD.collection[UD_str].name
if cs.socket_props_per_UD.collection[UD_str].bool_randomise:
self.sockets_to_randomise_per_UD[UD_str].append(sckt)
self.sockets_to_randomise_per_UD.append(sckt)

print(
"INVOKE ==== sockets to randomise ",
Expand Down Expand Up @@ -326,9 +326,10 @@ def execute(self, context):
# For every GNG with a subpanel - REFACTORING BASED ON NEW CODE
print(
"EXECUTE list_subpanel_prop_names ==== ",
self.list_subpanel_UD_props_names,
self.sockets_to_randomise_per_UD,
)
for UD_str in self.list_subpanel_UD_props_names:
# for UD_str in self.list_subpanel_UD_props_names:
for UD_str in self.sockets_to_randomise_per_UD:
# get collection of socket properties for this material
# NOTE: socket properties do not include the actual socket object
sockets_props_collection = cs.socket_props_per_UD.collection[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def candidate_UD_props(self): # getter method
# regex=re.compile(r'^test-\d+$')

if obj in obj_str:
print("Yay found cube")
# print("Yay found cube")
idx = i

# if (
Expand Down Expand Up @@ -230,7 +230,7 @@ def candidate_UD_props(self): # getter method
# list_materials,
# key=lambda mat: mat.name.lower()
# )
print(list_UD_props)
# print(list_UD_props)
return list_UD_props


Expand Down
42 changes: 21 additions & 21 deletions randomiser/define_prop/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def draw_sockets_list_UD(
row_split.column(align=True)

# input node name
print(list_UD_props_sorted)
# print(list_UD_props_sorted)
col1.label(text=sockets_props_collection.name) # UD.name
col1.alignment = "CENTER"

Expand Down Expand Up @@ -179,7 +179,7 @@ def draw_sockets_list_UD(
# regex=re.compile(r'^test-\d+$')

if obj in obj_str:
print("Yay found cube")
# print("Yay found cube")

idx = i
# attr_type = attr_get_type(
Expand Down Expand Up @@ -248,18 +248,18 @@ def attr_get_type(obj, path):
# len_path = len(full_str.rsplit(".", config.MAX_NUMBER_OF_SUBPANELS))
path_prop, path_attr = path.rsplit(".", 1)

print("if statement ==== ")
print(
"FROM rsplit . path_prop for resolve = ",
path_prop,
" and path_attr for getattr = ",
path_attr,
)
print("obj used for path_resolve = ", obj)
# print("if statement ==== ")
# print(
# "FROM rsplit . path_prop for resolve = ",
# path_prop,
# " and path_attr for getattr = ",
# path_attr,
# )
# print("obj used for path_resolve = ", obj)

# same as: prop = obj.modifiers["Subsurf"]
prop = obj.path_resolve(path_prop)
print("prop from path_resolve for get_attr = ", prop)
# print("prop from path_resolve for get_attr = ", prop)
else:
prop = obj
# single attribute such as name, location... etc
Expand All @@ -274,8 +274,8 @@ def attr_get_type(obj, path):
action = "dummy"
prop = "dummy"
path_attr = "dummy"
print(action, prop, path_attr)
print(type(action))
# print(action, prop, path_attr)
# print(type(action))
# action = getattr(prop, path_attr)

return type(action), action, prop, path_attr
Expand Down Expand Up @@ -510,7 +510,7 @@ def poll(cls, context):
# regex=re.compile(r'^test-\d+$')

if obj in obj_str:
print("Yay found ", obj)
# print("Yay found ", obj)

idx = i

Expand All @@ -526,10 +526,10 @@ def poll(cls, context):
bpy.context.scene, attribute_only_str
)[0]

print("prop_type", prop_type)
print("action", action)
print("prop", prop)
print("path_attr", path_attr)
# print("prop_type", prop_type)
# print("action", action)
# print("prop", prop)
# print("path_attr", path_attr)

else:
action = "dummy"
Expand Down Expand Up @@ -623,7 +623,7 @@ def draw(self, context):
# full_list = [prop.name for prop in list(C.scene.custom)]
list_all_UD_props = []
for UD_str in bpy.context.scene.custom:
print("ERROR ====== UD_str", UD_str)
# print("ERROR ====== UD_str", UD_str)
objects_in_scene = []
for key in bpy.data.objects:
objects_in_scene.append(key.name)
Expand All @@ -636,7 +636,7 @@ def draw(self, context):
# regex=re.compile(r'^test-\d+$')

if obj in obj_str:
print("Yay found cube")
# print("Yay found cube")

idx = i

Expand Down Expand Up @@ -671,7 +671,7 @@ def draw(self, context):
# )[1]
# != "dummy"
# ]
print("list_all_UD_props ====== ", list_all_UD_props)
# print("list_all_UD_props ====== ", list_all_UD_props)
# print(
# "bpy.context.scene.custom_index == ",
# bpy.context.scene.custom_index,
Expand Down

0 comments on commit b420f6d

Please sign in to comment.