-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
Input socket types for nodes #341
Comments
I would love having this feature. I think you could do the following to implement this feature.
Something like this could work for 3. class A:
@overload
def __getitem__(self, key: Literal[1]) -> Literal["a"]: ...
@overload
def __getitem__(self, key: Literal["a"]) -> Literal["a"]: ...
@overload
def __getitem__(self, key: Literal[2]) -> Literal["b"]: ...
@overload
def __getitem__(self, key: Literal["b"]) -> Literal["b"]: ...
def __getitem__(self, key: int | str) -> Any: ... What is describe above do not require a change to the Blender documentation. You may need to make a PR to Blender to surface the node type information @nutti, may have more to say on this. |
Iterating over the node inputs does return the class of the socket at runtime, will try writing something that should be able to dump that type information into a definition file. Thanks for the tips! |
Incredibly embarrassed to have come up with this, but this seems to work? import bpy
for node in bpy.types.ShaderNode.__subclasses__():
obj = bpy.context.selected_objects[0].material_slots[0].material.node_tree
m = obj.nodes.new(node.__name__)
print("--------------")
print(m.__class__.__name__)
print("--------------")
for i, input in enumerate(m.inputs):
print(f"[{i}]: {input.__class__.__name__}: {input.name}") |
I agree with your idea. @Surasia |
Description about the feature
When creating nodes, it doesn't seem possible to use the "default_value" attribute for a
NodeSocket
, as those are defined for subclasses ofNodeSocket
such asNodeSocketFloat
.For instance, this code accesses the second input of a math node:
This however throws a type error as .default_value may is not defined in the
NodeSocket
class. It's possible to work around this by overriding the type of the input:Unfortunately, the documentation does not seem to specify the types for each input in a node socket, so I'm not sure if an implementation is possible.
Are you willing to contribute about this feature.
Yes, contributing to blender docs to specify input types.
The text was updated successfully, but these errors were encountered: