2025-01-22 16:18:30 +01:00
|
|
|
from lnx.logicnode.lnx_nodes import *
|
|
|
|
|
|
|
|
|
|
class GetChildNode(LnxLogicTreeNode):
|
2026-09-04 10:46:13 -07:00
|
|
|
"""Returns the child of the given object by name or by a specific type."""
|
2025-01-22 16:18:30 +01:00
|
|
|
bl_idname = 'LNGetChildNode'
|
|
|
|
|
bl_label = 'Get Object Child'
|
|
|
|
|
lnx_section = 'relations'
|
|
|
|
|
lnx_version = 1
|
|
|
|
|
|
2026-09-04 10:46:13 -07:00
|
|
|
def sw_update(self, context):
|
|
|
|
|
self.inputs[1].hide = (self.property0 == 'By Type')
|
|
|
|
|
|
2025-01-22 16:18:30 +01:00
|
|
|
property0: HaxeEnumProperty(
|
|
|
|
|
'property0',
|
|
|
|
|
items = [('By Name', 'By Name', 'By Name'),
|
|
|
|
|
('Contains', 'Contains', 'Contains'),
|
|
|
|
|
('Starts With', 'Starts With', 'Starts With'),
|
|
|
|
|
('Ends With', 'Ends With', 'Ends With'),
|
2026-09-04 10:46:13 -07:00
|
|
|
('By Type', 'By Type', 'By Type')],
|
|
|
|
|
name='Method', default='By Name', update=sw_update)
|
|
|
|
|
|
|
|
|
|
property1: HaxeEnumProperty(
|
|
|
|
|
'property1',
|
|
|
|
|
items = [('MeshObject', 'Mesh', 'MeshObject'),
|
|
|
|
|
('CameraObject', 'Camera', 'CameraObject'),
|
|
|
|
|
('LightObject', 'Light', 'LightObject'),
|
|
|
|
|
('SpeakerObject', 'Speaker', 'SpeakerObject'),
|
|
|
|
|
('DecalObject', 'Decal', 'DecalObject'),
|
|
|
|
|
('ProbeObject', 'Probe', 'ProbeObject'),
|
|
|
|
|
('CurveObject', 'Curve', 'CurveObject')],
|
|
|
|
|
name='Type', default='MeshObject')
|
2025-01-22 16:18:30 +01:00
|
|
|
|
|
|
|
|
def lnx_init(self, context):
|
|
|
|
|
self.add_input('LnxNodeSocketObject', 'Parent')
|
|
|
|
|
self.add_input('LnxStringSocket', 'Child Name')
|
|
|
|
|
self.add_output('LnxNodeSocketObject', 'Child')
|
|
|
|
|
|
|
|
|
|
def draw_buttons(self, context, layout):
|
|
|
|
|
layout.prop(self, 'property0')
|
2026-09-04 10:46:13 -07:00
|
|
|
|
|
|
|
|
if self.property0 == 'By Type':
|
|
|
|
|
layout.prop(self, 'property1')
|