clone shader node

Plugins linking to this thread: (hide)

Clone ShaderAuthor: caledonian tartan
Duplicates a node and creates expressions on each parameters of the clone to have them driven by the original parameter. Installs into the context menu of render tree nodes.

local backup: CloneShaderNode.xsiaddon (repackaged/fix for local backup)

Discussions about rendering in SOFTIMAGE©
Post Reply
caledonian_tartan
Posts: 253
Joined: 17 Feb 2010, 15:13

clone shader node

Post by caledonian_tartan » 27 Jan 2015, 16:31

i'm about to create a function to clone a shadernode oder icenode inside the rendertree or Icetree.

is fairly simple to place a plugin in the rightclick menu context of a icenode/shadernode:

Code: Select all

	in_reg.RegisterMenu(constants.siMenuICENodeContextID,"test_Menu",false,false)
or
	in_reg.RegisterMenu(constants.siMenuRTNodeContextID,"test_Menu",false,false)
Duplicate(clone) and linking all parameters is a bit harder...
As duplicate does't seem to work, i use copy/paste.

Code: Select all

Application.Copy("Sources.Materials.DefaultLib.Scene_Material.Phong")
Application.Paste("Sources.Materials.DefaultLib.Scene_Material")
how do i get this context without using the explicit names?
how do i get all the node's parameters i just right clicked on to be linked to the new copy?

(using python)
SI 2015 @ WIN7-64

caledonian_tartan
Posts: 253
Joined: 17 Feb 2010, 15:13

Re: clone shader node

Post by caledonian_tartan » 28 Jan 2015, 17:27

currently i should just know how to define the selected node to get the Node.Name...
:ympray:
SI 2015 @ WIN7-64

User avatar
FXDude
Posts: 1129
Joined: 19 Jun 2012, 21:59

Re: clone shader node

Post by FXDude » 29 Jan 2015, 09:59

I'm pretty sure there's a way to get selected node(s),

A bit in a crunch right now but I'll look into it soon,

And that will be a neat addition to many toolboxes if you would care to share.
(once it works :) )

caledonian_tartan
Posts: 253
Joined: 17 Feb 2010, 15:13

Re: clone shader node

Post by caledonian_tartan » 29 Jan 2015, 14:23

that would be cool, FXDUDE!

there is a way to use the view attributes.

i'm about to collect some info. about basic scripting. again. ~x(

I try to point out the steps:

right click on a Node (ICE or Render Tree) --> Should give the name of the selected node : i can create that right click command, but not return the selected node
click on clone (custom command) --> Copy/Paste the selected node and link all parameters to the master : not there yet

this should be VERY easy, but i don't even get around the selection.
even with the help of our promising SDK Explorer.

but shure, if it works, i'll share it like all the stuff i got help on from the forum.
SI 2015 @ WIN7-64

caledonian_tartan
Posts: 253
Joined: 17 Feb 2010, 15:13

Re: clone shader node

Post by caledonian_tartan » 02 Feb 2015, 13:10

with this JS it is possible to get the selected node in the active render tree.

how can i list its parameters?

this line: "LogMessage( oNode.Parameters );" gives a type mismatch error. why?

Code: Select all

// Get Selected Node

// Get the Render Tree view
var oLayout = Application.Desktop.ActiveLayout;
var oRTViews = oLayout.Views.Filter( "Render Tree" );
 
// Now get the selected nodes 
// and log the names of the selected nodes
var x = oRTViews(0);
var a = x.GetAttributeValue( "selection" ).split(",");
LogMessage( a.length );
 
for ( var i in a )
{
    var oNode = Dictionary.GetObject( a[i] );
    LogMessage( oNode.Name );
//	LogMessage( oNode.Parameters );
}
Last edited by caledonian_tartan on 02 Feb 2015, 13:53, edited 1 time in total.
SI 2015 @ WIN7-64

caledonian_tartan
Posts: 253
Joined: 17 Feb 2010, 15:13

Re: clone shader node

Post by caledonian_tartan » 02 Feb 2015, 13:53

This Python Script goes one step further:

you can log the selected Node in the render tree and
you can log its parameters

Code: Select all

a = Application
log = a.LogMessage

### Get The Active View

oLayout = a.Desktop.ActiveLayout
oRTViews = oLayout.Views.Filter( "Render Tree" )

x = oRTViews(0)
y = x.GetAttributeValue( "selection" ).split(",")

### Get The Shader Parameters

a.SelectObj(y, "", "")

oNode = a.Selection(0)

for p in oNode.Parameters:
	log(p)
cool.

next is linking parameter arrays. OMG...

The Main Issue is to filter out Parameters like "Name" or "Mode" which i don't want to clone.

Any chance to just get parameters that are able to be linked by an expression?

(also it seems that - on the diffuse or other color parameters, there are RGB/HLS/HSV values to set)
SI 2015 @ WIN7-64

caledonian_tartan
Posts: 253
Joined: 17 Feb 2010, 15:13

Re: clone shader node

Post by caledonian_tartan » 03 Mar 2015, 17:47

i finally had some time to work on this.

here it is. a little helper to clone shader nodes.

it works in most cases. sometimes it does not. (Hair_Gradient_Material)
clonenode.jpg
CloneShaderNodePlugin.zip
(1.78 KiB) Downloaded 91 times
SI 2015 @ WIN7-64

User avatar
FXDude
Posts: 1129
Joined: 19 Jun 2012, 21:59

Re: clone shader node

Post by FXDude » 04 Mar 2015, 01:52

Very nice work (!) and thanks so much for such a nifty handy tool (to say the least)!

Should submit to RRay!

And kudos on overcoming all these obstacles (among probably others)

Cheers

Post Reply

Who is online

Users browsing this forum: No registered users and 28 guests