# How to get the max and min value of a certain NodeSocket's slider?

I'm rather new to scripting in Blender and have stumbled upon a problem I can't find a solution to. I'm trying to find the max and min value of an input of a Node. I manage to find the input object (they're subclasses of NodeSocket) but I can't find any way to extract its max or min value. I reckon that many of them doesn't have it set, but how come then that the slider to control them seem to have a min and max? Can I extract this?

To clarify, for a Nodes input X, a slider might be restricted to values between 0 and 10 by default. If i force it to, say -10 then the slider will adapt and range between -10 and 10. Can I extract this first range somehow? Is it manually set or somehow automatically calculated in Blender?

In the below image, Blender restricts the slider to 0.1 - 20.0.

UPDATE The node in question is a custom Group Node node and comes from this Blende-file, maybe that has something to do with it?

## 1 Answer

These are blender properties

https://docs.blender.org/api/current/bpy.props.html In defining, for example a float type property bpy.props.FloatProperty can set its hard and soft minimums and maximums.

A soft setting is the first range you force the property past up till the hard setting.

As an example using the Principled BSDF node

>>> node_tree = D.materials['Material'].node_tree
>>> node = node_tree.nodes['Principled BSDF']


Each inputs default_value property settings can be found via input.bl_rna.properties["default_value"]

Loop over the enumerated inputs of the node and output the index, name, mins, and maxes of their default_value property.

>>> for i, inp in enumerate(node.inputs):
...     i, inp.name
...     p = inp.bl_rna.properties["default_value"]
...     p.hard_min, p.soft_min, p.soft_max, p.hard_max
...
(0, 'Base Color')
(0.0, 0.0, 1.0, 3.4028234663852886e+38)
(1, 'Subsurface')
(0.0, 0.0, 1.0, 1.0)
(2, 'Subsurface Radius')
(-3.4028234663852886e+38, -10000.0, 10000.0, 3.4028234663852886e+38)
(3, 'Subsurface Color')
(0.0, 0.0, 1.0, 3.4028234663852886e+38)
(4, 'Metallic')
(0.0, 0.0, 1.0, 1.0)
(5, 'Specular')
(0.0, 0.0, 1.0, 1.0)
(6, 'Specular Tint')
(0.0, 0.0, 1.0, 1.0)
(7, 'Roughness')
(0.0, 0.0, 1.0, 1.0)
(8, 'Anisotropic')
(0.0, 0.0, 1.0, 1.0)
(9, 'Anisotropic Rotation')
(0.0, 0.0, 1.0, 1.0)
(10, 'Sheen')
(0.0, 0.0, 1.0, 1.0)
(11, 'Sheen Tint')
(0.0, 0.0, 1.0, 1.0)
(12, 'Clearcoat')
(0.0, 0.0, 1.0, 1.0)
(13, 'Clearcoat Roughness')
(0.0, 0.0, 1.0, 1.0)
(14, 'IOR')
(-3.4028234663852886e+38, -10000.0, 10000.0, 3.4028234663852886e+38)
(15, 'Transmission')
(0.0, 0.0, 1.0, 1.0)
(16, 'Transmission Roughness')
(0.0, 0.0, 1.0, 1.0)
(17, 'Emission')
(0.0, 0.0, 1.0, 3.4028234663852886e+38)
(18, 'Alpha')
(0.0, 0.0, 1.0, 1.0)
(19, 'Normal')
(-3.4028234663852886e+38, -10000.0, 10000.0, 3.4028234663852886e+38)
(20, 'Clearcoat Normal')
(-3.4028234663852886e+38, -10000.0, 10000.0, 3.4028234663852886e+38)
(21, 'Tangent')
(-3.4028234663852886e+38, -10000.0, 10000.0, 3.4028234663852886e+38)


Note a property may not be a float type. Autocomplete on property definition p to see options and values.

• Thank you, that helps a lot. It doesn't seem to be correct though, as my slider for "Groove scale" shown in the picture has a step of 0.1 and soft min = 0 and soft max = 10, but the properties states a step of 10 and soft min / soft max of [-10000, 10000]. How come? – Zorobay Jan 28 at 1:46
• No idea. I have no idea what node that is. – batFINGER Jan 28 at 10:27
• I've updated my question with a source. It seems like it is NOT a problem with GroupNode, as I tried this on the IOR output of a standard Principled BSDF node where the slider goes from 0 to 1000 in steps of 0.1. Still, the properties tells me the soft_max and soft_min are -10000 and 10000 with a step of 0.1. – Zorobay Jan 29 at 0:55
• @Zorobay Good question, there's something totally off. The limits defined in static bNodeSocketTemplate sh_node_bsdf_principled_in (node_shader_bsdf_principled.c) are how the UI actually behaves, it allows a range from 0 to 1000. I'll have to check where the wrong values for the limits come from. – Robert Gützkow Jan 29 at 18:21
• The limits for the properties on nodes are a bit odd anyway, since the hard limits aren't validated. – Robert Gützkow Jan 29 at 18:39