creating and connecting to existing nodes

Forums: creating and connecting to existing nodes
Forum for OctaneRender Lua scripting examples, discussion and support.

creating and connecting to existing nodes

Postby gah5118 » Thu Apr 29, 2021 5:30 pm

gah5118 Thu Apr 29, 2021 5:30 pm
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.
Windows 8.1 | i7 950 | GTX 780ti | 24gb ddr3
gah5118
Licensed Customer
Licensed Customer
 
Posts: 356
Joined: Thu Jun 02, 2011 4:25 pm

Re: creating and connecting to existing nodes

Postby gah5118 » Fri May 07, 2021 1:27 pm

gah5118 Fri May 07, 2021 1:27 pm
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!
Windows 8.1 | i7 950 | GTX 780ti | 24gb ddr3
gah5118
Licensed Customer
Licensed Customer
 
Posts: 356
Joined: Thu Jun 02, 2011 4:25 pm

Re: creating and connecting to existing nodes

Postby grimm » Fri May 07, 2021 7:35 pm

grimm Fri May 07, 2021 7:35 pm
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
Linux Mint 20 x64 | Nvidia GTX 980 4GB (displays) RTX 2070 8GB| Intel I7 5820K 3.8 Ghz | 32Gb Memory | Nvidia Driver 460.56
User avatar
grimm
Licensed Customer
Licensed Customer
 
Posts: 1293
Joined: Wed Jan 27, 2010 8:11 pm
Location: Spokane, Washington, USA

Re: creating and connecting to existing nodes

Postby gah5118 » Fri May 07, 2021 8:55 pm

gah5118 Fri May 07, 2021 8:55 pm
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!
Windows 8.1 | i7 950 | GTX 780ti | 24gb ddr3
gah5118
Licensed Customer
Licensed Customer
 
Posts: 356
Joined: Thu Jun 02, 2011 4:25 pm

Re: creating and connecting to existing nodes

Postby gah5118 » Fri May 07, 2021 8:56 pm

gah5118 Fri May 07, 2021 8:56 pm
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)
Windows 8.1 | i7 950 | GTX 780ti | 24gb ddr3
gah5118
Licensed Customer
Licensed Customer
 
Posts: 356
Joined: Thu Jun 02, 2011 4:25 pm

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 2 guests

Wed Jun 23, 2021 6:27 pm [ UTC ]