Material linker

Forums: Material linker
Forum for OctaneRender Lua scripting examples, discussion and support.

Material linker

Postby lance_uppercut » Mon Sep 10, 2018 10:54 pm

lance_uppercut Mon Sep 10, 2018 10:54 pm

I'm sharing a script that I wrote to help deal with the large number of materials and meshes I have in my architectural scenes. I used to spend a lot of time connecting pins to each other for every new mesh in my scene, and it was tedious especially with so many lines covering the scene graph. This script runs through all the material input pins of the selected meshes, and matches them to material output pins that reside inside a separate node graph where I have all my materials. Here's how it's used:

Inside your materials node graph, the output pins should be named to match the material names that come in with your mesh. (I work in Sketchup and bring in OBJ files)

Select at least one mesh, and ONE node graph with the materials.

Run the script (shortcut is ALT-L) and all names that match will be linked up.

One more thing to note, there is a variable at the top of the lua file that goes:

local copy_materials = false
change this to
local copy_materials = true
and the script will COPY the materials rather than linking them. This will NOT copy any material input nodes, like diffuse textures, that are expanded out of the material. To get them to copy over, you have to collapse these other nodes into the material node. Roeland's script Move Nodes into Node Pins can help with this:
(3.5 KiB) Downloaded 182 times
Licensed Customer
Licensed Customer
Posts: 6
Joined: Fri Jan 23, 2015 12:51 am
Location: Toronto, Canada

Return to Lua Scripting

Who is online

Users browsing this forum: No registered users and 1 guest

Wed Jan 20, 2021 7:46 am [ UTC ]