3
$\begingroup$

I'm attempting to find a way to identify the unique properties from material nodes to put into a collection instead of accessing their values by their name. Nodes have collections for inputs, outputs, links, etc. I'm looking for a similar type collection for the node's unique properties.

For example, the Ambient Occlusion node has three unique properties(inside, only local, samples) which values can be accessed from ShaderNodeAmbientOcclusion by using their name. ie. node.samples. I can get a list of all properties from the node.bl_rna.properties.items() but I don't know to identify the uncommon attributes.

Also, the draw_buttons_ext seems to have this list for each node when it creates the panel, but I don't know if there is a way to access this through the ui or node objects.

The current solution I thought of was to create a list of common properties from a node object and identify the ones that don't match, but this doesn't feel like the right way to go about it.

$\endgroup$
3
  • 1
    $\begingroup$ I can't think of a better way than grabbing props that the superclass doesn't have. The draw_buttons functions just hardcode the properties for every node type, eg. for ambient occlusion. $\endgroup$
    – scurest
    Dec 22, 2021 at 0:42
  • $\begingroup$ Thanks! I thought there might be a hidden property type or flag that I could access for built-in properties that weren't custom, but I guess there wasn't a need for that level of identity. $\endgroup$
    – jedv
    Dec 22, 2021 at 4:47
  • 1
    $\begingroup$ Possibly related: What's the most reliable way of converting a material into reusable code blocks? $\endgroup$ Dec 22, 2021 at 10:22

1 Answer 1

1
$\begingroup$

I spent a good while poking around on the console and arrived at this. It's a bit late but I'm posting in case it helps anyone.

[attribute for attribute in node.bl_rna.properties.keys() if attribute not in bpy.types.Node.bl_rna.properties.keys()]

Will get a list of properties that are not in the base Node class.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .