@@ -72,7 +72,30 @@ def process(self, instance):
7272 rop_node = hou .node (instance .data ["instance_node" ])
7373
7474 save_layers = []
75- for layer in instance .data .get ("layers" , []):
75+ stack = list (instance .data .get ("layers" , []))
76+ processed = set (stack )
77+ for layer in stack :
78+ # We need to proceed into sublayers and external references
79+ # because these can also have configured save paths that we need
80+ # to collect. This logic mimics Houdini's `scenegraphlayers` model
81+ # used by the Scene Graph Layers panel in Solaris. Fix: #361
82+ # Note: We use `list` over `set` here just to match the behavior of
83+ # Houdini's Scene Graph Layers panel to increase our chances the
84+ # sorting of the layers is somewhat similar to what artists see in
85+ # the panel. (It's purely for cosmetic reasons though)
86+ child_sublayers = list (layer .subLayerPaths )
87+ child_refs = list (ref for ref in layer .externalReferences
88+ if ref and ref not in layer .subLayerPaths )
89+ for child_layer in child_sublayers :
90+ child_layer = Sdf .Layer .FindOrOpen (child_layer )
91+ if child_layer not in processed :
92+ stack .append (child_layer )
93+ processed .add (child_layer )
94+ for child_layer in child_refs :
95+ child_layer = Sdf .Layer .FindOrOpen (child_layer )
96+ if child_layer not in processed :
97+ stack .append (child_layer )
98+ processed .add (child_layer )
7699
77100 info = layer .GetPrimAtPath ("/HoudiniLayerInfo" )
78101 if not info :
0 commit comments