Get only visible details and properties of a node in python

Hello, from the list of a node’s properties I’m trying to retrieve only those that are visible to the final user and their relative displayed label, as shown in the following image:

image

When I get the list of properties, each one of them has a bunch of parameters but I don’t understand which of these are the ones that I need. I’ve checked properties such as is_visible, is_hidden, is_registered, description and so on, but I couldn’t figure out which determines the visibility to the final user and which contains the displayed text on the left.

For example, in the Attribute node, both the Location and the Attribute Type properties has is_visible = False, but in reality Attribute Type is visible, as well as Attribute Name (as you can see in the image above).
I’ve made lots of cross-checks like this for the other properties as well, but with no success.

I frankly think that the Blender scripting is not very well documented (at least on the official site)… I tried to check the documentation, but I couldn’t find what I need (maybe it’s just that I’m not good at reading the documentation?).
I hope that someone could help me, and thank you!

In user preferences you can enable developer extras, user tooltips and python tooltips

user prefs

Which will allow mouse over popups to provide details assisting with which property you want.

mouse over

2 Likes

That’s a very interesting tip! I’ll have to change my code a bit but now I know how to retrieve the correct informations. The only unsolved thing is about the labels, which are not showed in details while hovering the mouse over them.

The labels are part of the property, or attribute in this case. They’re not stored separately, but they’re included in the attribute definition :slight_smile: to change the name, change the property

1 Like

As @joseph mentioned “name” and “type” descriptions that you highlighted are not user defined but are a part of the definition of the node template.

Technically they can be found at:
bpy.data.materials['Material'].node_tree.nodes['Attribute'].bl_rna.properties['name'].name

‘Name’

bpy.data.materials['Material'].node_tree.nodes['Attribute'].bl_rna.properties['type'].name

‘Type’

But because these are part of the definition creating the node and all future nodes of the same type they are not accessible.

bpy.data.materials['Material'].node_tree.nodes['Attribute'].bl_rna.properties['name'].name = 'test'

Traceback (most recent call last):
File “<blender_console>”, line 1, in
AttributeError: bpy_struct: attribute “name” from “StringProperty” is read-only

2 Likes

Thank you for these tips!
One thing I noticed after enabling the Developer extras option is that not every properties are shown in the tooltip. For example, the values in the RGB Curves node are not described when hovering with the mouse, as well as the channels (the CRGB above the graph).

image

is there any other option to enable for these particular values?

Things of that nature are, generally speaking, not accessible through the Python API. Not every field in Blender can be accessed through the Python API, and if it doesn’t have a tooltip, that’s often why.

In this case, however, you’re in luck- those are accessible through the API, but as “points” on a curve, not as the values as you see them:
https://blender.stackexchange.com/questions/111325/using-python-how-can-i-preset-points-in-shadernode-rgb-curves

2 Likes
import bpy


# note 'Material.001' is a specific material name that may not match yours
mat = bpy.data.materials['Material.001']

# again specific named curve node that may not match yours
rgb_curve = mat.node_tree.nodes['RGB Curves']

# the curves (combined, red, green, blue are in 
curves = rgb_curve.mapping.curves
# curves[0] - red
# curves[1] - green
# curves[2] - blue
# curves[3] - combined

# the points on the curve are found in
pts = curves[0].points # red curve note above indexing


# as such you can get the point locations like 
for pt in pts:
    print(pt.location)

Shown as an x,y vector

<Vector (0.0045, 0.3500)>
<Vector (0.2955, 0.2688)>
<Vector (0.6682, 0.3187)>
<Vector (1.0000, 1.0000)>

1 Like

Well, at this point I think I don’t have anymore questions. you have been very efficient and exhaustive and I thank you one last time :smiley:. I just wonder how you guys manage to find these informations so easily, as I tried to read the docs but that didn’t do much.