connecting node to a nodegraph

Forums: connecting node to a nodegraph
Forum for OctaneRender Lua scripting examples, discussion and support.

connecting node to a nodegraph

Postby gah5118 » Wed Mar 22, 2023 4:56 pm

gah5118 Wed Mar 22, 2023 4:56 pm
I am trying to connect an alembic nodegraph inside an orbx nodegraph to a output geometry node

I have tried a few ways but am just beating my head against the wall at this point. the last method I was attempting was to have it create the output node in the selected graph, then clear the selection and select the output node along with the geometry.abc node. up to this point is successful, but getting the two to connect just doesn't want to work out. I have been able to connect standard nodes, but the error "[string "setupscript.lua"]:60: bad argument #1 to 'connectTo' (octane.node expected, got octane.nodegraph)" comes up when trying to connect it to the alembic node.

Code: Select all
outlink = octane.node.create{ type=octane.NT_OUT_GEOMETRY, name="output", graphOwner=octane.project.getSelection()[1] }
obg = octane.project.getSelection()[1]:findItemsByName("geometry.abc")
print_table(obg)
octane.project.clearSelection()
octane.project.select(outlink)
octane.project.select(obg[1])
print_table(octane.project.getSelection())
--outlink:connectTo(octane.project.getSelection()[1],)
octane.node.connectTo(octane.project.getSelection()[1],octane.project.getSelection()[2])
Windows 8.1 | i7 950 | GTX 780ti | 24gb ddr3
gah5118
Licensed Customer
Licensed Customer
 
Posts: 358
Joined: Thu Jun 02, 2011 4:25 pm

Re: connecting node to a nodegraph

Postby gah5118 » Wed Mar 22, 2023 5:42 pm

gah5118 Wed Mar 22, 2023 5:42 pm
figured it out finally... my code is below. it's a mess and has a lot of my print test to understand how the commands were behaving. hoping it might help someone in the same situation.

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)
nodetest = octane.nodegraph.getOutputNodes(selection)
print("nodetest= ")
print_table(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)


outlink = octane.node.create{ type=octane.NT_OUT_GEOMETRY, name="output", graphOwner=octane.project.getSelection()[1] }
obg = octane.project.getSelection()[1]:findItemsByName("geometry.abc")
print_table(obg)
print("endtable1")

outputnodesnames = octane.nodegraph.getOutputNodes(obg[1])
print_table(outputnodesnames)
print("end outputnames")

print_table(octane.node.getPinInfoIx(outputnodesnames[1], 1))
print("end outputnames info")

octane.project.clearSelection()
octane.project.select(outlink)
--octane.project.select(obg[1])
print_table(octane.project.getSelection())
print("end selection print")
outlink:connectTo(82, outputnodesnames[1])
--octane.node.connectTo(octane.project.getSelection()[1],octane.project.getSelection()[2])



this is the cleaned up code

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


outlink = octane.node.create{ type=octane.NT_OUT_GEOMETRY, name="output", graphOwner=octane.project.getSelection()[1] }


outputnodesnames = octane.nodegraph.getOutputNodes(obg[1])


octane.project.clearSelection()
octane.project.select(outlink)


outlink:connectTo(82, outputnodesnames[1])

Windows 8.1 | i7 950 | GTX 780ti | 24gb ddr3
gah5118
Licensed Customer
Licensed Customer
 
Posts: 358
Joined: Thu Jun 02, 2011 4:25 pm

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 5 guests

Thu Mar 28, 2024 3:27 pm [ UTC ]