Created
April 18, 2017 13:10
-
-
Save zeffii/c1429b16c591c1469527e1636c8f5da5 to your computer and use it in GitHub Desktop.
custom socket drawing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
from bpy.props import FloatVectorProperty | |
from bpy.props import FloatProperty, BoolProperty | |
from sverchok.node_tree import SverchCustomTreeNode | |
from sverchok.data_structure import updateNode | |
from sverchok.core.socket_data import SvGetSocketInfo | |
socket_colors = { | |
"COLOR": (0.899, 0.8052, 0.0, 1.0), | |
"QUATERNION": (0.9, 0.4, 0.7, 1.0) | |
} | |
class SvFKB(bpy.types.Node, SverchCustomTreeNode): | |
''' a SvFKB f ''' | |
bl_idname = 'SvFKB' | |
bl_label = 'SvFKB _ :)' | |
bl_icon = 'GREASEPENCIL' | |
quaternion_a = FloatVectorProperty(subtype='QUATERNION', min=0, max=0, size=4, default=(0,0,0,1)) | |
expand_a = BoolProperty() | |
expand_b = BoolProperty() | |
def sv_init(self, context): | |
A = self.inputs.new('StringsSocket', "Float") | |
A.prop_name = 'quaternion_a' | |
A.custom_draw = 'draw_one_socket' | |
A.nodule_color = socket_colors['QUATERNION'] | |
OUT = self.outputs.new('StringsSocket', "Float") | |
OUT.nodule_color = socket_colors['QUATERNION'] | |
def draw_buttons(self, context, layout): | |
layout.label('helios') | |
def draw_one_socket(self, socket, context, layout): | |
node = self | |
if not socket.is_linked: | |
c = layout.column(align=True) | |
c.prop(node, socket.prop_name, text='') | |
else: | |
if socket.prop_name: | |
prop = node.rna_type.properties.get(socket.prop_name, None) | |
t = prop.name.split('_')[1].upper() | |
else: | |
t='' | |
layout.label(t + '. ' + SvGetSocketInfo(socket)) | |
def process(self): | |
_in = self.inputs[0].sv_get() | |
self.outputs[0].sv_set(_in) | |
def register(): | |
bpy.utils.register_class(SvFKB) | |
def unregister(): | |
bpy.utils.unregister_class(SvFKB) | |
if __name__ == '__main__': | |
register() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment