Hi @cgweasel, to retrieve the selected node, like all BaseList2D
(BaseOject,BaseTag,BaseMaterial, etc...) you can know there selection state with the method node.GetBit(c4d.BIT_ACTIVE)
.
So find bellow the complete code to do what you want:
import c4d
def main():
# Checks if selected material is valid
mat = doc.GetActiveMaterial()
if not mat or not mat.CheckType(1036224) :
raise ValueError("There is no xpresso redshift material selected")
# Retrieve the output nodes, which is also the first node in the node hierarchy.
# Therefor we can iterate them as usual BaseList2D
node = mat[c4d.REDSHIFT_GRAPH_NODES]
while node:
# Check if this is a texture node and its selected
if node[c4d.GV_REDSHIFT_SHADER_META_CLASSNAME] == 'TextureSampler' and node.GetBit(c4d.BIT_ACTIVE):
# Set to Raw, to know the Id and the value I left click on the Filename parameter, User Interface -> Show SubChannel
# Then I dragged the ColorSpace parameter to the python console
node[c4d.REDSHIFT_SHADER_TEXTURESAMPLER_TEX0,c4d.REDSHIFT_FILE_COLORSPACE] = "RS_INPUT_COLORSPACE_RAW"
node = node.GetNext()
c4d.EventAdd()
if __name__=='__main__':
main()
Cheers,
Maxime.