All,
I have been unable to figure out how to get the paths to any texture image files used within a material.
I would like to get all image files a material might use, i.e. normal and bump maps as well as diffuse and specular. Could anyone enlighten me.
Many thanks
Mark
Getting the path to a texture image file from material nodes
Windows 11, 2x Intel I9, 64GB Ram, 2x GTX 1080 TI, 1 x RTX 380 TI, Oculus Quest 2
You can recursively walk over all the input nodes of the given node:
To check if any node has a file name attribute, you can use
This code gives you the file names of any kind of file referenced by the nodes, not just image textures.
--
Roeland
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
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
Many Thanks Roeland
Windows 11, 2x Intel I9, 64GB Ram, 2x GTX 1080 TI, 1 x RTX 380 TI, Oculus Quest 2