Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
Hi,
Does not work color_space_port= node.GetInputs().FindChild("com.redshift3d.redshift4c4d.nodes.core.texturesampler.tex0.colorspace")
color_space_port= node.GetInputs().FindChild("com.redshift3d.redshift4c4d.nodes.core.texturesampler.tex0.colorspace")
What works tex_parent_port = node.GetInputs().FindChild("com.redshift3d.redshift4c4d.nodes.core.texturesampler.tex0") color_space_port= tex_parent_port .FindChild("colorspace")
tex_parent_port = node.GetInputs().FindChild("com.redshift3d.redshift4c4d.nodes.core.texturesampler.tex0")
color_space_port= tex_parent_port .FindChild("colorspace")
I initially thought that just appending and hard coding the string works. But apparently, it does not. I have to use the FindChild even though I already know the actual path of the parameter/port.
FindChild
Is this how it really behaves or am I missing something?
P.S. I understand that its trivial. But I guess its more pythonic to just use the "." notation to retrive the parameters/attributes of a node.
For example, texturenode.tex0.colorspace texturenode.uv.uv_channel texturenode.remape.scale.x
texturenode.tex0.colorspace
texturenode.uv.uv_channel
texturenode.remape.scale.x
easier to read rather than daisy chaining several FindChild methods.
Hello @bentraje,
Thank you for reaching out to us.
FindChild takes an Id or node kind as its argument, ...texturesampler.tex0 is a valid node ID for the Redshift Texture node, ...texturesampler.tex0.colorspace is not, there is simply no such node.
...texturesampler.tex0
...texturesampler.tex0.colorspace
The Filename (com.redshift3d.redshift4c4d.nodes.core.texturesampler.tex0) in-port of the Redshift Texture node is a port bundle, i.e., is a port that has child-ports. Its child port Color Space for example, has simply the ID colorspace and its Path child port the ID path.
com.redshift3d.redshift4c4d.nodes.core.texturesampler.tex0
colorspace
path
I guess you want to save some vertical script space, the things you can do are:
colorSpaceOutPort = node.GetInputs().FindChild("com.redshift3d.redshift4c4d.nodes.core.texturesampler.tex0").FindChild("colorspace")
maxon.GraphModelHelper.ListAllNodess
GraphModelHelper
Texture>Filename>Color Space
GraphNode.FindInnerNode
I personally would not do any of this. The Nodes API can produce code that is longer than one is comfortable with, this is true. But if you start condensing your code to extreme levels of abstraction, you won't be able to read any of it six months later (the "when I wrote this, only God and I knew what it meant, now only God knows"-effect). Be verbose in your code, especially when an API is complex, this is the best thing you can do for readability and maintainability.
We are aware of the problems of the Nodes API, and that especially technical artist type users wish for easier interfaces, "to just plug things together". But the Nodes API effectively implements a modern graph database model which is inherently complex. So, it is at least not easy to do this, without nullifying everything the Nodes API want to achieve: A strong abstraction of a scene/material graph. As indicated by GraphModelHelper, we are already working on this, but the Nodes API will probably be never as straight forward as a classic API scene graph was, simply because it is much more abstract.
What also plays into this, is that maxon attributes for Redshift IDs have not been exposed. It makes a big difference if you have to write node.GetInputs().FindChild("com.redshift3d.redshift4c4d.nodes.core.texturesampler.tex0") or if you can write node.GetInputs().FindChild(maxon.redshift.texturesampler.filename), but the C++ maxon attributes which would be necessary for this to trickle down to Python do not yet exist. I am lobbying for this since R25, but the Redshift team never got to it, next time we will talk, I will bug them again about this
node.GetInputs().FindChild("com.redshift3d.redshift4c4d.nodes.core.texturesampler.tex0")
node.GetInputs().FindChild(maxon.redshift.texturesampler.filename)
Cheers, Ferdinand
@ferdinand
Thanks for the clarification and offering some alternatives. I guess it has something do with how it was designed.
There is a FindChild equivalent in other DCC API too like in maya there is a GetAttr or something. But again, if you know the actual parameter/attribute path like texturenode.tex0.colorspace texturenode.uv.uv_channel texturenode.remape.scale.x There's no need. It's straightforward. You use that instead.
GetAttr
Anyhow, will close this thread now.