Page 1 of 1

C4D How to manipulate nodes in the Node Editor using Python?

PostPosted: Mon Mar 25, 2024 7:00 pm
by aliaboshady123
I'm trying to automate something that I do manually all the time and it takes a long time. I have this Octane material that has these nodes that I want to edit. Basically set each of these shaders' files. So how do I get a references to these 52 nodes in the image? And to go a step further, is there a way to create them in any Octane material (and then get their references)?

Image

I also have this simple script that opens the Octane Node Editor of the selected object. Not sure if this would be needed.

Code: Select all
def main():
    materials=doc.GetMaterials()
    obj =doc.GetActiveObject()

    if not obj:
        c4d.gui.MessageDialog("Please select an object or a material tag.")
        return

    objMaterial= obj.GetTag(c4d.Ttexture)
    if objMaterial == None:
        c4d.gui.MessageDialog("Selected object has not a material tag.")
       
    c4d.CallButton(objMaterial.GetMaterial(), c4d.OCT_MATERIAL_NODE_EDITOR)
   
    c4d.EventAdd()
if __name__=='__main__':
    main()