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])