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,
I'm trying to write a script that modify the selected nodes only if the node is an RS Texture node. And the way I can know if its an RS Texture Node is if it has the tex0 attribute (see below)
tex0
My logic is something like this:
rs_texture_node = node.GetInputs().FindChild("com.redshift3d.redshift4c4d.nodes.core.texturesampler.tex0") if rs_texture_node.IsValid(): # Do something here
It works if the node selected is a texture node but throws a ValueError: no target to copy for '<net.maxon.graph.interface.graphmodel>' if its otherwise.
ValueError: no target to copy for '<net.maxon.graph.interface.graphmodel>'
Which I don't get. It's either the node/port is valid or not. Why throw an error?
Hello @bentraje,
Thank you for reaching out to us. This is an error which is raised in the C++ part of our Python API (and not just the Python frameworks trampoline code). It happens when something is meant to be wrapped into a CPyObject (so that Python can deal with it) and the something is a null pointer.
CPyObject
Without executable code it will be hard for us to replicate your problem. As always, you can send code to us privately via sdk_support(at)maxon(dot)net. In the meantime you could try if you have better luck with maxon.Data.IsNullValue() which we have added with 2023.0.0. It tests for a reference being the empty reference, i.e., what you want to do here. maxon.GraphNode is an instance of maxon.Data. So, you would have to do this isNull: bool = rs_texture_node.IsNullValue(). When you search for garbage, e.g., FindChild("blahblah"), the value should be true.
sdk_support(at)maxon(dot)net
maxon.Data.IsNullValue()
2023.0.0
maxon.GraphNode
maxon.Data
isNull: bool = rs_texture_node.IsNullValue()
FindChild("blahblah")
Cheers, Ferdinand
@ferdinand
Thanks for response.
RE: added 2023. I'm still at R25 so I can't use that route unfortunately.
Anyhow, I just settled on the GetId() which works the same way. It's just that doing a split method is bit awkward.
GetId()
split
if node.GetId().split("@")[0] == 'texturesampler': texPort = node.GetInputs().FindChild("com.redshift3d.redshift4c4d.nodes.core.texturesampler.tex0") # do something more for the texPort
Hi @bentraje, as Ferdinand said without more code is hard to help you. Happy that you solved it, I just wanted to warn you that your code will not work anymore in newer version, since in 2023.0 everything that return a maxon.Id, does return a maxon.Id and not anymore a python string. So if yo uwant to be future proof, use if str(node.GetId()).split("@")[0] == 'texturesampler':
maxon.Id
if str(node.GetId()).split("@")[0] == 'texturesampler':
Cheers, Maxime.
@m_adam
Gotcha. Thanks for the heads up!