Skip to content

Commit 6836b70

Browse files
author
Jaap-Jan
authored
added function to lightgroup to add every light
added function to lightgroup to add every light
2 parents a9d3489 + c451c38 commit 6836b70

3 files changed

Lines changed: 45 additions & 0 deletions

File tree

otls/create_otl_20.5.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,15 @@ def _get_metadata_block():
857857
)
858858
)
859859

860+
light_groups.addParmTemplate(
861+
hou.ButtonParmTemplate(
862+
"add_all_lights_to_lightgroups",
863+
"Add all lights",
864+
script_callback="hou.phm().add_all_lights_to_lightgroups(kwargs['node'])",
865+
script_callback_language=hou.scriptLanguage.Python,
866+
)
867+
)
868+
860869
light_group_item = hou.FolderParmTemplate(
861870
"light_groups_select",
862871
"Light Groups",

otls/python_functions_20.5.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,42 @@ def setup_light_groups(karma_node: hou.Node) -> None:
207207
add_all_automated_lightgroups_to_render_vars(light_groups_info, karma_node)
208208

209209

210+
def add_all_lights_to_lightgroups(karma_node: hou.Node) -> None:
211+
"""adds all the lights that are found in stage.
212+
213+
Args:
214+
karma_node: SGTK Karma node
215+
"""
216+
stage = hou.node("/stage")
217+
stage_nodes = stage.children()
218+
light_types = [
219+
"<hou.OpNodeType for Lop light::2.0>",
220+
"<hou.OpNodeType for Lop domelight::3.0>",
221+
"<hou.OpNodeType for Lop distantlight::2.0>",
222+
"<hou.OpNodeType for Lop karmaphysicalsky>",
223+
"<hou.OpNodeType for Lop karmaskydomelight>"
224+
]
225+
226+
lightgroup_names = []
227+
lightgroup_paths = []
228+
229+
for node in stage_nodes:
230+
if str(node.type()) in light_types:
231+
relative_path = node.path().replace("/stage/", "../")
232+
lightgroup_paths.append(relative_path)
233+
lightgroup_names.append(node.name())
234+
235+
karma_node.parm("light_groups_select").set(str(len(lightgroup_names)))
236+
237+
light_group_multiparm_count = karma_node.parm("light_groups_select").eval()
238+
239+
for light_group_index in range(1, light_group_multiparm_count + 1):
240+
light_group_name_parm = f"light_group_name_{light_group_index}"
241+
selected_light_lops_parm = f"select_light_lops_{light_group_index}"
242+
243+
karma_node.parm(light_group_name_parm).set(lightgroup_names[light_group_index - 1])
244+
karma_node.parm(selected_light_lops_parm).set(lightgroup_paths[light_group_index - 1])
245+
210246
def add_all_automated_prefs_to_render_vars(karma_node: hou.Node) -> None:
211247
"""Adds all our prefs to the karma render settings additional
212248
render variables.

otls/sgtk_karma.otl

153 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)