-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Programatically specify the input group behaviour at the modifier panel #38
Comments
An implementation was started, but not completed here: Lines 35 to 39 in da99654
It would allow you to write something like this: def min_max_demo(value: Int[slice(0, 1)]):
pass It's just a matter of completing the implementation. |
The API should probably be extended to support more options: def test(value: Int[0, 1]): pass # min, max
def test(value: Int["My Value"]): pass # custom input name
def test(value: Int[InputOptions(min=0, max=1, tooltip="The value you want", ...)]): pass # full-featured configuration Alternatively, wrapper types could be used. I find this is a bit more confusing to read though: def test(value: MinMax[Int, 0, 1]): pass
def test(value: Named[Int, "My Value"]): pass
def test(value: Tooltip[MinMax[Int, 0, 1], "The value you want"]): pass |
Great, thanks, so this will be coming eventually ... |
I started looking at the source code, in order to try to complete the implementation. But I have a question regarding the missing parts of the implementation. I see at several places in the code base that a value gets assigned to the |
Got one microstep further in understanding things. Could not find any attributes at he output sockets of the input group which suggest they serve to set
I can set visually in the UI things like |
@rsaccon the min and max have to be set via the node_group = bpy.data.node_groups['my_node']
node_group.interface.items_tree["Value"].default_value = 1
node_group.interface.items_tree["Value"].min_value = 1
node_group.interface.items_tree["Value"].max_value = 0 |
@BradyAJohnston That really helped. Thanks a lot. |
After trying to halfway understand what is going on under the hood at Geometry Script, I managed to implement min and max input options at my fork. The API looks like this right now: # min
def test(value: Int[0]): pass
def test(value: Float[0.0]): pass
# min, max
def test(value: Int[0, 1]): pass
def test(value: Float[0.0, 1.0]): pass
# min, max (slice notation)
def test(value: Int[0:1]): pass
def test(value: Float[0.0:1.0]): pass Before making a PR I want to test some more edge cases and properly handle them. And extend with an |
Now I got stuck with trying to set the input subtype (such as Distance, Percentage, etc). While it is straight forward to set name, default, min, max and tooltip just by setting the proper input socket attribute, for the subtype it seems an operator needs to be called (just setting the attribute only changes the selector label but not the value). If I do it by hand in the Node UI, then this shows up in the console log:
so I try to do it programmatically in the console and it fails: >>> bpy.ops.node.tree_socket_change_subtype(socket_subtype='DISTANCE')
...
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
File "/Applications/Blender36.app/Contents/Resources/3.6/scripts/modules/bpy/ops.py", line 113, in __call__
ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.node.tree_socket_change_subtype.poll() failed, context is incorrect next I try set the context. After taking a look at the node input options UI source code, I come up with another failed attempt:
So how do I set the right context ??? The second attempt failed because there is no |
I did another attempt and I finally managed to change the input subtype (just in the python console for now), but there is still a context error:
here is the poll source code of the I don't know what is causing that exception. Maybe my approach to set the context is wrong. Anyway, I will continue now to implement this input options in my fork, for vectors as well. |
My suggested solution for this issue is in this PR, so closing this. |
When directly editing nodes, there is the Group Input Panel to specify Input Default, Min, Max and more, see screenshot below. But with Geometry Script what I have found out so far, only Default can be set. Is there a way to programatically set the other fields from that panel ? For numbers it would be great to be able to specify Min and Max
The text was updated successfully, but these errors were encountered: