You can recursively walk over all the input nodes of the given node:
- Code: Select all
local function walk(node, list)
-- recursive walk
for i = 1,node:getPinCount() do
local src = node:getInputNodeIx(i)
if src ~= nil then walk(src, list) end
end
-- see if this node has a filename attribute
local ok, value = pcall(node.getAttribute, node, "filename")
if ok then
table.insert(list, value)
end
end
local list = {}
walk(octane.project.getSelection()[1], list)
for k, v in ipairs(list) do
print(v)
end
To check if any node has a file name attribute, you can use
pcall
, a standard Lua function which calls another function (
octane.node.getAttribute
in our case) with the given arguments and catches any errors raised.
This code gives you the file names of
any kind of file referenced by the nodes, not just image textures.
--
Roeland