You can access this information for every IntProperty
and FloatProperty
through Python. It requires the access of RNA properties. The approach is the same for UI sliders as it is for node sockets, but as an easier introduction the first example uses a property of Eevee's render settings.
Example 1 - Regular UI Property
Let's start with finding the limits of Eevee's bloom threshold. The value that is currently set can be accessed through:
bpy.context.scene.eevee.bloom_threshold
This will only give us the current float value. If we want to get the property, we have to access the RNA. The following code gets the underlying FloatProperty
.
bpy.context.scene.eevee.bl_rna.properties["bloom_threshold"]
There are four limits to the property soft_min
, soft_max
, hard_min
and hard_max
. The soft limits are used for the minimum and maximum value that can be reached through the slider, while the hard limits are the actual maximum and minimum values that can be entered manually.*
* This doesn't seem to apply to the nodes though, they allow to enter float values higher than the hard limits.
bloom_threshold = bpy.context.scene.eevee.bl_rna.properties["bloom_threshold"]
print(f"soft_min: {bloom_threshold.soft_min}")
print(f"soft_max: {bloom_threshold.soft_max}")
print(f"hard_min: {bloom_threshold.hard_min}")
print(f"hard_max: {bloom_threshold.hard_max}")
For the bloom threshold the values are:
soft_min: 0.0
soft_max: 10.0
hard_min: 0.0
hard_max: 100000.0
Example 2 - Node Socket
The following example assumes that the material with the node exists. Normally you would need to check for the existence of the keys first.
Assume that you have a material called Material which contains a node Noise Texture for which you would like to know the limits of the input Scale and the output Fac.
First the node has to be accessed (assuming that all these elements exist):
noise_texture = bpy.data.materials["Material"].node_tree.nodes["Noise Texture"]
For the limits of the Scale input we need to access the Property that is behind default_value
of the socket that we're interested in. Scale is an input socket.
scale_property = noise_texture.inputs["Scale"].bl_rna.properties["default_value"]
print(f"soft_min: {scale_property.soft_min}")
print(f"soft_max: {scale_property.soft_max}")
print(f"hard_min: {scale_property.hard_min}")
print(f"hard_max: {scale_property.hard_max}")
The limits are:
soft_min: -10000.0
soft_max: 10000.0
hard_min: -3.4028234663852886e+38
hard_max: 3.4028234663852886e+38
The same approach can be used to find the limits of an output socket, like Fac.
fac_property = noise_texture.outputs["Fac"].bl_rna.properties["default_value"]
print(f"soft_min: {fac_property.soft_min}")
print(f"soft_max: {fac_property.soft_max}")
print(f"hard_min: {fac_property.hard_min}")
print(f"hard_max: {fac_property.hard_max}")
The limits for this socket are:
soft_min: 0.0
soft_max: 1.0
hard_min: 0.0
hard_max: 1.0
There may be cases where the limits change dynamically, which isn't covered by this answer. It looks like a similar approach could possibly work for Vector sockets, where the limits likely apply for each dimension.