Update Files
This commit is contained in:
70
leenkx/blender/lnx/logicnode/math/LN_math_term.py
Normal file
70
leenkx/blender/lnx/logicnode/math/LN_math_term.py
Normal file
@ -0,0 +1,70 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
import re
|
||||
|
||||
class MathTermNode(LnxLogicTreeNode):
|
||||
"""Formula for symbolic Math"""
|
||||
bl_idname = 'LNMathTermNode'
|
||||
bl_label = 'Math Term'
|
||||
lnx_version = 0
|
||||
|
||||
num_params: IntProperty(default=2, min=0)
|
||||
|
||||
property0: HaxeBoolProperty('property0', name='Resolve params', description='Resolve input param values/subterms for output term/transformations', default=False)
|
||||
|
||||
def __init__(self):
|
||||
super(MathTermNode, self).__init__()
|
||||
self.register_id()
|
||||
|
||||
|
||||
def lnx_init(self, context):
|
||||
|
||||
# OUTPUTS:
|
||||
self.add_output('LnxDynamicSocket', 'Math Term')
|
||||
self.add_output('LnxDynamicSocket', 'Simplifyed')
|
||||
self.add_output('LnxDynamicSocket', 'Derivate')
|
||||
self.add_output('LnxFloatSocket', 'Result')
|
||||
self.add_output('LnxStringSocket', 'Error')
|
||||
self.add_output('LnxIntSocket', 'ErrorPos')
|
||||
|
||||
# INPUTS:
|
||||
|
||||
# HOW to setup a Tooltip here and how to put it above the param-add/remove-buttons into layout ?
|
||||
self.add_input('LnxStringSocket', 'Math Term', default_value='a+b')
|
||||
|
||||
# two default parameters at start
|
||||
self.add_input('LnxStringSocket', 'Param 0', default_value='a')
|
||||
self.add_input('LnxDynamicSocket', 'Value / Term 0')
|
||||
|
||||
self.add_input('LnxStringSocket', 'Param 1', default_value='b')
|
||||
self.add_input('LnxDynamicSocket', 'Value / Term 1')
|
||||
|
||||
def add_sockets(self):
|
||||
self.add_input('LnxStringSocket', 'Name ' + str(self.num_params))
|
||||
#self.add_input('LnxFloatSocket', 'Value ' + str(self.num_params))
|
||||
self.add_input('LnxDynamicSocket', 'Value / Term ' + str(self.num_params))
|
||||
self.num_params += 1
|
||||
|
||||
def remove_sockets(self):
|
||||
if self.num_params > 0:
|
||||
self.inputs.remove(self.inputs.values()[-1])
|
||||
self.inputs.remove(self.inputs.values()[-1])
|
||||
self.num_params -= 1
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
# Bind values to params Property
|
||||
layout.prop(self, 'property0')
|
||||
|
||||
# Button ADD parameter
|
||||
row = layout.row(align=True)
|
||||
column = row.column(align=True)
|
||||
op = column.operator('lnx.node_call_func', text='Add Param', icon='PLUS', emboss=True)
|
||||
op.node_index = self.get_id_str()
|
||||
op.callback_name = 'add_sockets'
|
||||
|
||||
# Button REMOVE parameter
|
||||
column = row.column(align=True)
|
||||
op = column.operator('lnx.node_call_func', text='', icon='X', emboss=True)
|
||||
op.node_index = self.get_id_str()
|
||||
op.callback_name = 'remove_sockets'
|
||||
if self.num_params == 0:
|
||||
column.enabled = False
|
Reference in New Issue
Block a user