I thought I would share two scripts that could come in handy.
Good luck with your projects! =D
-------------------
Creates shaders of your choice to selected objects:
Suggested usage:
When working with new scene from scratch or export to Substance.
- Code: Select all
// Creates Shaders to selected objects
// Select objects in scene and run
// Michael Blackshore 2015 (C)
// Usage is without any restrictions
string $selectedObjs[] = `ls -sl`; //get selected objects
for ($obj in $selectedObjs){ //iterate on selected objects
string $newMat = `shadingNode -asShader "octaneDiffuseMaterial"`; // creates a diffuse. Switchable to the materials below:
// octaneMixMaterial= Mix material
// octaneSpecularMaterial= Specular
// octaneGlossyMaterial = Glossy
// octanePortalMaterial = Portal
string $rnMat = `rename $newMat ($obj + "_Diffuse_Mat")`; //renames to Mesh name + Diffuse_MAT [not needed]
string $newSG = `sets -renderable true -noSurfaceShader true -empty -name ($rnMat + "SG")`; //create a shading group
connectAttr -f ($rnMat + ".outColor") ($newSG + ".surfaceShader"); //connect shading group to lambert
sets -e -forceElement $newSG $obj; //connect material to object
}
-------------------
Replace textures in existing shader three.
Suggested usage:
Comes in handy when does multiple objects of the same type, examples, books in bookshelfs, plates etc.
- Code: Select all
// Replaces textures in existing shader three.
// Select octane Image textures in Hypergraph and run.
// Row 13 contains source and target. It will search for First input and replace it with the second.
// Michael Blackshore 2015 (C)
// Usage is without any restrictions
string $octaneTextures[] = `ls -sl`;
for ($i=0; $i< (`size $octaneTextures`); $i++){
if (`attributeExists "File" $octaneTextures[$i]`){
string $texture = `getAttr ($octaneTextures[$i] + ".File")`;
//replace old path with new path
string $result = substituteAllString($texture, "R_A", "L_A"); // Edit The two inputs to your need.
//sets attribute in node
setAttr -type "string" ($octaneTextures[$i] + ".File") $result;
print ($result + "\n");
}
}