Jump to content

Getting node parm in material graph


Recommended Posts

I am trying to get the parameters of nodes in a Redshift material but when iterating over "childNode.GetOperatorContainer()" I get an error on some nodes, where others act just fine.

 

 

(Sorry if my C4D nomenclature is wrong. I am not use to code for C4D 🙂 )

 

Here's my example

import c4d
import redshift as rs

def main():
  
    doc = c4d.documents.GetActiveDocument()

    nodemaster = rs.GetRSMaterialNodeMaster(doc.GetActiveMaterial())
    shadergraph = nodemaster.GetRoot()

    # Iterate over all the nodes in the material graph
    for childNode in shadergraph.GetChildren():

        print("Node: {}".format(childNode.GetName()))

        # Get number of parameters
        print(len(childNode.GetOperatorContainer()))
        
        for parameter in childNode.GetOperatorContainer():
            print(parameter)

if __name__=='__main__':
    main()

 

If I run this over a "RS Material" node it's just fine

Output:

Node: RS Material
99
(1000, 6)
(1001, 'Material')
(1002, <c4d.BaseContainer object at 0x000001ACF0BE7870>)
(10112, 65536)
(10000, Vector(0.5, 0.5, 0.5))
(10001, 1.0)
(10002, 0.0)
(10003, Vector(0.5, 0.5, 0.5))
(10004, 0.0)
(10005, Vector(1, 1, 1))
(10006, 1.0)
(10007, 0.0)
(10008, 16)
(10009, 0)
(10010, 0.0)
(10011, 0.0)
(10012, 3)
(10013, Vector(0.04, 0.04, 0.04))
(10014, Vector(0, 0, 0))
(10015, Vector(1.5, 1.5, 1.5))
(10016, Vector(0, 0, 0))
(10017, 0.0)
(10018, 1.5)
(10019, Vector(1, 1, 1))
(10020, 0.0)
(10021, 0.0)
(10022, 8)
(10023, 1.5)
(10024, 1)
(10025, 0.0)
(10026, 0)
(10113, 0)
(10027, Vector(1, 1, 1))
(10114, 0.009999999776482582)
(10115, Vector(0, 0, 0))
(10116, 0.009999999776482582)
(10117, Vector(1, 1, 1))
(10029, 0.0)
(10030, 0.0)
(10031, 16)
(10035, 0.0)
(10036, 100.0)
(10151, 1)
(10152, 64)
(10153, 1)
(10037, Vector(1, 0.9, 0.7))
(10038, 1.0)
(10039, 1.0)
(10040, Vector(1, 0.9, 0.7))
(10041, 0.0)
(10042, 1.0)
(10043, Vector(1, 0.9, 0.7))
(10044, 0.0)
(10045, 1.0)
(10046, Vector(1, 1, 1))
(10047, 0.0)
(10048, 0.0)
(10049, 16)
(10050, 0)
(10051, 3)
(10052, Vector(0.027, 0.027, 0.027))
(10053, Vector(1.4, 1.4, 1.4))
(10054, 1.399999976158142)
(10055, Vector(1, 1, 1))
(10056, 0.10000000149011612)
(10057, Vector(0, 0, 0))
(10058, Vector(1, 1, 1))
(10059, Vector(1, 1, 1))
(10060, Vector(0, 0, 0))
(10061, 0.0)
(10062, Vector(0, 0, 0))
(10064, 0)
(10065, 3)
(10066, 0)
(10067, 0.009999999776482582)
(10068, 1)
(10069, 5)
(10070, 0)
(10071, 0.009999999776482582)
(10119, 6)
(10072, 1.0)
(10073, 1.0)
(10074, 1.0)
(10075, 1.0)
(10076, 0)
(10077, 1.0)
(10078, 1.0)
(10079, 0)
(10080, 0)
(10081, 0)
(10118, 0.0)
(10120, 1)
(10121, 1)
(10082, 1)
(10083, 0)
(10155, 1)
(10085, 2)
(10086, '')
(10087, '')

 

But if I try to iterate over a "RS Texture" node I get this error:

Node: RS Texture
26
(1000, 6)
Traceback (most recent call last):
  File "C:\material_information\material_information.py", line 23, in <module>
    main()
  File "C:\material_information\material_information.py", line 20, in main
    print(parameter)
AttributeError: Parameter value not accessible (object unknown in Python)

 

Link to post

I don't have Redshift, but it looks as if the internal C++ (?) incarnation of the data structure uses objects which have not been implemented in module rs. That is not necessarily an error if these classes are not meant to be accessed by end users - or maybe the API programmers have not gotten around to implement them yet.

Which means you cannot extract these values from the container, but you could probably catch the error and just skip that value. (Of course, if you need to evaluate all parameters for some reason, then you have lost the game here.)

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...