Page 1 of 1

creating and connecting to existing nodes

PostPosted: Thu Apr 29, 2021 5:30 pm
by gah5118
I have been trying to find an example for my situation but have had no luck so far.

what i am trying to create (with no lua experience):

in every scene is a geometry node inside a group (imported orbx) and a perspective camera. the names of these nodes never change (geometry.abc) (perspShape)

I want to create and connect output nodes for each.

I found how to create nodes and connect to other nodes that are created, but not how to connect to existing nodes.

the result should be the geometry.abc and perspShape connected to output nodes.

Re: creating and connecting to existing nodes

PostPosted: Fri May 07, 2021 1:27 pm
by gah5118
is it even possible to connect existing nodes together? Or, is it required that the nodes be created via Lua in order to do so?

if it is possible to connect nodes, and in this case, nodegraphs (the abc node) to nodes, how would one go about it?

thanks!

Re: creating and connecting to existing nodes

PostPosted: Fri May 07, 2021 7:35 pm
by grimm
Now it's been a while, but you should be able to read the nodegraph for all of it's nodes. Then choose the one you want and connect it. The nodegraph is hierarchical so you will have to parse the tree to find the node you need. There are functions that allow you to search the tree for specific types of nodes and then from that list you should be able to find the node you need. I wish I could go into more detail, but I just don't have the time and things could have changed since I last did some scripting in Octane.

Jason

Re: creating and connecting to existing nodes

PostPosted: Fri May 07, 2021 8:55 pm
by gah5118
grimm wrote:Now it's been a while, but you should be able to read the nodegraph for all of it's nodes. Then choose the one you want and connect it. The nodegraph is hierarchical so you will have to parse the tree to find the node you need. There are functions that allow you to search the tree for specific types of nodes and then from that list you should be able to find the node you need. I wish I could go into more detail, but I just don't have the time and things could have changed since I last did some scripting in Octane.

Jason


Thanks for the feedback!

Re: creating and connecting to existing nodes

PostPosted: Fri May 07, 2021 8:56 pm
by gah5118
here's what i have so far. it's a mess, I know. i'm just digging across the forums and hacking together what i can find.

Code: Select all
function print_table(table, str)
    --print a table plus an optional extra string
    for i,n in pairs(table) do
        print(i,n)
    end
    print(str)
end

function rndPos()
    return { math.random(400, 600), math.random(400, 600) }
end

--get selection
selection = octane.project.getSelection()[1]
print(selection)


--outLink = octane.node.create{ type=octane.NT_OUT_GEOMETRY, name="Output", graphOwner=selection, position=rndPos() }
nodetest = octane.nodegraph.findFirstOutputNode(selection, octane.PT_GEOMETRY)   
print("nodetest= ")
print(nodetest)
print("end")
-- I have tried this.
    nodes = octane.nodegraph.findNodes(selection, octane.NT_OUT_GEOMETRY, true);
print("nodes=")
print_table(nodes)
    for i,entry in ipairs(nodes) do
        print(entry)
        for s=1,entry.pinCount do
                print(octane.node.getConnectedNodeIx(entry,s))
        end
    end
print("====ending======")

--[string "newgetselection.lua"]:23: attempt to index a nil value (global 'node')

--octane.GT_GEOMETRYARCHIVE
--PT_GEOMETRY

--NT_OUT_GEOMETRY
--p_INPUT

nodesfound = octane.nodegraph.findNodes(selection, octane.GT_GEOMETRYARCHIVE)
print("table:")
print_table(nodesfound)

 info = octane.nodegraph.getOutputNodes(selection)
print("whats in info:")
print_table(info)