From 0d1870ff5a262c9afd28777c575971742f5b79c9 Mon Sep 17 00:00:00 2001 From: Ondrej Samohel Date: Thu, 13 Apr 2023 16:44:19 +0200 Subject: [PATCH] :recycle: enhance sop node selection logic if selected node is sop node, it will be used for path, otherwise it will try to find output node with lowest index under selected node --- .../houdini/plugins/create/create_bgeo.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/openpype/hosts/houdini/plugins/create/create_bgeo.py b/openpype/hosts/houdini/plugins/create/create_bgeo.py index 46fa47df92..468215d76d 100644 --- a/openpype/hosts/houdini/plugins/create/create_bgeo.py +++ b/openpype/hosts/houdini/plugins/create/create_bgeo.py @@ -38,13 +38,17 @@ class CreateBGEO(plugin.HoudiniCreator): } if self.selected_nodes: - parms["soppath"] = self.selected_nodes[0].path() - - # try to find output node - for child in self.selected_nodes[0].children(): - if child.type().name() == "output": - parms["soppath"] = child.path() - break + # if selection is on SOP level, use it + if isinstance(self.selected_nodes[0], hou.SopNode): + parms["soppath"] = self.selected_nodes[0].path() + else: + # try to find output node with the lowest index + outputs = [ + child for child in self.selected_nodes[0].children() + if child.type().name() == "output" + ] + outputs.sort(key=lambda output: output.evalParm("outputidx")) + parms["soppath"] = outputs[0].path() instance_node.setParms(parms) instance_node.parm("trange").set(1)