-
-
Save zeffii/24f6aa4c8c804fdcb476 to your computer and use it in GitHub Desktop.
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 node_s import * | |
from util import * | |
from bpy.props import FloatProperty | |
class SvFloatOp(bpy.types.Operator): | |
bl_idname = "node.float_config" | |
bl_label = "Sverchok floatnode op" | |
bl_options = {'REGISTER', 'UNDO'} | |
def execute(self, context): | |
n = context.node | |
n.rna_type.float_[1]['hard_max'] = n.hard_max | |
n.rna_type.float_[1]['hard_min'] = n.hard_min | |
n.rna_type.float_[1]['soft_max'] = n.soft_max | |
n.rna_type.float_[1]['soft_min'] = n.soft_min | |
return {'FINISHED'} | |
class FloatNode2(Node, SverchCustomTreeNode): | |
''' Float2 ''' | |
bl_idname = 'FloatNode2' | |
bl_label = 'Float2' | |
bl_icon = 'OUTLINER_OB_EMPTY' | |
float_ = FloatProperty( | |
name='float_', | |
description='float number', | |
default=1.0, options={'ANIMATABLE'}, | |
update=updateNode) | |
hard_max = FloatProperty(name='hard_max', default=10.0) | |
hard_min = FloatProperty(name='hard_min', default=-10.0) | |
soft_max = FloatProperty(name='soft_max', default=1.0) | |
soft_min = FloatProperty(name='soft_min', default=-1.0) | |
def init(self, context): | |
# self.inputs.new('StringsSocket', "Float", "Float").prop_name = 'float_' | |
self.outputs.new('StringsSocket', "Float", "Float").prop_name = 'float_' | |
def draw_buttons(self, context, layout): | |
layout.prop(self, "float_", text="float") | |
def draw_buttons_ext(self, context, layout): | |
row = layout.row(align=True) | |
row.label('slider limits') | |
for propname in ['hard_max', 'hard_min', 'soft_max', 'soft_min']: | |
row = layout.row(align=True) | |
row.prop(self, propname, text=propname) | |
row = layout.row(align=True) | |
row.operator('node.float_config', text='set these') | |
def update(self): | |
# need input? make a throughput node instead? 'identity node' | |
# if 'Float' in self.inputs and self.inputs['Float'].links: | |
# tmp = SvGetSocketAnyType(self,self.inputs['Float']) | |
# Float = tmp[0][0] | |
# else: | |
# Float = self.float_ | |
if 'Float' in self.outputs and self.outputs['Float'].links: | |
SvSetSocketAnyType(self,'Float',[[self.float_]]) | |
def update_socket(self, context): | |
self.update() | |
def register(): | |
bpy.utils.register_class(FloatNode2) | |
bpy.utils.register_class(SvFloatOp) | |
def unregister(): | |
bpy.utils.unregister_class(SvFloatOp) | |
bpy.utils.unregister_class(FloatNode2) | |
if __name__ == "__main__": | |
register() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment