Коммит 04e703b3 создал по автору Durman's avatar Durman
Просмотр файлов

add list available sockets for group tree

fix displaying property in GroupOutputNode
fix showing default properties of generated Interface socket classes
владелец 86957d45
......@@ -17,6 +17,7 @@ from sverchok.core.main_tree_handler import empty_updater
from sverchok.data_structure import extend_blender_class
from mathutils import Vector
from sverchok.core.sockets import socket_type_names
from sverchok.core.group_handlers import MainHandler, NodeIdManager
from sverchok.core.events import GroupEvent
from sverchok.utils.tree_structure import Tree, Node
......@@ -125,11 +126,14 @@ class SvGroupTree(SvNodeTreeCommon, bpy.types.NodeTree):
n_in_s.use_prop = not t_in_s.hide_value
if hasattr(t_in_s, 'default_type'):
n_in_s.default_property_type = t_in_s.default_type
for node in (n for n in self.nodes if n.bl_idname == 'NodeGroupOutput'):
for n_in_s, t_out_s in zip(node.inputs, self.outputs):
n_in_s.use_prop = not t_out_s.hide_value
if hasattr(t_out_s, 'default_type'):
n_in_s.default_property_type = t_out_s.default_type
for out_node in (n for n in self.nodes if n.bl_idname == 'NodeGroupOutput'):
for n_in_s, t_out_s in zip(out_node.inputs, self.outputs):
if hasattr(n_in_s, 'default_property'):
n_in_s.use_prop = not t_out_s.hide_value
if hasattr(t_out_s, 'default_type'):
n_in_s.default_property_type = t_out_s.default_type
else:
n_in_s.use_prop = False
def check_reroutes_sockets(self):
"""
......@@ -258,6 +262,12 @@ class SvGroupTree(SvNodeTreeCommon, bpy.types.NodeTree):
return group_nodes
raise LookupError(f'Path the group tree: {self} was not found')
if bpy.app.version >= (3, 2): # in 3.1 this can lead to a crash
@classmethod
def valid_socket_type(cls, socket_type: str):
# https://docs.blender.org/api/master/bpy.types.NodeTree.html#bpy.types.NodeTree.valid_socket_type
return socket_type in socket_type_names()
class BaseNode:
n_id: bpy.props.StringProperty(options={'SKIP_SAVE'})
......
......@@ -16,6 +16,9 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
import inspect
import sys
from typing import Set
from mathutils import Matrix, Quaternion
import bpy
......@@ -73,6 +76,17 @@ def update_interface(self, context):
if input_node:
group_tree.update_nodes([input_node])
def socket_type_names() -> Set[str]:
names = set()
for name, member in inspect.getmembers(sys.modules[__name__]):
is_module_cls = inspect.isclass(member) and member.__module__ == __name__
if is_module_cls:
if NodeSocket in member.__bases__:
names.add(member.bl_idname)
return names
class SV_MT_AllSocketsOptionsMenu(bpy.types.Menu):
bl_label = "Sockets Options"
......@@ -1481,13 +1495,17 @@ def socket_interface_classes():
prop_args['name'] = "Default value"
prop_args['update'] = lambda s, c: s.id_data.update_sockets()
socket_interface_attributes['__annotations__'] = {}
socket_interface_attributes['__annotations__']['default_value'] = (prop_func, prop_args)
socket_interface_attributes['__annotations__']['default_value'] = socket_cls.__annotations__['default_property']
def draw(self, context, layout):
col = layout.column()
col.prop(self, 'default_value')
col.prop(self, 'hide_value')
socket_interface_attributes['draw'] = draw
else:
def draw(self, context, layout):
pass
socket_interface_attributes['draw'] = draw
yield type(
f'{socket_cls.__name__}Interface', (bpy.types.NodeSocketInterface,), socket_interface_attributes)
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать