I tested the refs.dependencylooptest way but the problem seem to be that it doesn't stop at the immediate child or parent, but crawl all the way up or down the shading tree and that the node is a child and parent of itself (at least in my findings).
In the following example there is from down to up the tree:
bitmap > color map > color correct > standard material
Using this code:
fn delete_and_relink =
(
local mk_scene_nodes_all = join mk_scene_nodes mk_scene_nodes_unsupported
local child_node = undefined
local middle_node = undefined
local parent_node = undefined
-- here I loop in my unsupported nodes array
for i in mk_scene_nodes_unsupported do
(
middle_node = i
-- here I check against all nodes, supported or not for child
for j in mk_scene_nodes_all do
(
if ( refs.dependencyLoopTest middle_node j ) then
(
child_node = j
print ( middle_node as string + " CHILD is: " + child_node as string )
)
if ( refs.dependencyLoopTest j middle_node ) then
(
parent_node = j
print ( middle_node as string + " PARENT is: " + parent_node as string )
)
else ()
)
)
)
on testbtn pressed do ( delete_and_relink() )
For now this function does not delete and relink but that's its goal.
The output is:
"Material #25:Standard CHILD is: Material #25:Standard"
"Material #25:Standard PARENT is: Material #25:Standard"
"Material #25:Standard CHILD is: Map #4:Bitmap"
"Material #25:Standard CHILD is: Map #2:Color Correction"
"Material #25:Standard CHILD is: Map #3:Color Map"
"Map #4:Bitmap PARENT is: Material #25:Standard"
"Map #4:Bitmap CHILD is: Map #4:Bitmap"
"Map #4:Bitmap PARENT is: Map #4:Bitmap"
"Map #4:Bitmap PARENT is: Map #2:Color Correction"
"Map #4:Bitmap PARENT is: Map #3:Color Map"
"Map #2:Color Correction PARENT is: Material #25:Standard"
"Map #2:Color Correction CHILD is: Map #4:Bitmap"
"Map #2:Color Correction CHILD is: Map #2:Color Correction"
"Map #2:Color Correction PARENT is: Map #2:Color Correction"
"Map #2:Color Correction CHILD is: Map #3:Color Map"
"Map #3:Color Map PARENT is: Material #25:Standard"
"Map #3:Color Map CHILD is: Map #4:Bitmap"
"Map #3:Color Map PARENT is: Map #2:Color Correction"
"Map #3:Color Map CHILD is: Map #3:Color Map"
"Map #3:Color Map PARENT is: Map #3:Color Map"
as you can see this is not exactly what I'm after. Each node is a parent/child of itself and a given node will have as parent and children ALL the nodes up or down the tree.
Although if I could stop at the immediate parent and child, the problem of deleting the 'middle' node so it's parent and child have a direction connection is still open.