33 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
from lnx.logicnode.lnx_nodes import *
 | 
						|
 | 
						|
class SetParentNode(LnxLogicTreeNode):
 | 
						|
    """Sets the direct parent (nearest in the hierarchy) of the given object.
 | 
						|
    @input Object: Object to be parented.
 | 
						|
    @input Parent: New parent object. Use `Get Scene Root` node to unparent object.
 | 
						|
    @input Keep Transform: Keep transform after unparenting from old parent
 | 
						|
    @input Parent Inverse: Preserve object transform after parenting to new object.
 | 
						|
 | 
						|
    @seeNode Get Object Parent"""
 | 
						|
    bl_idname = 'LNSetParentNode'
 | 
						|
    bl_label = 'Set Object Parent'
 | 
						|
    lnx_section = 'relations'
 | 
						|
    lnx_version = 2
 | 
						|
 | 
						|
    def lnx_init(self, context):
 | 
						|
        self.add_input('LnxNodeSocketAction', 'In')
 | 
						|
        self.add_input('LnxNodeSocketObject', 'Object')
 | 
						|
        self.add_input('LnxNodeSocketObject', 'Parent')
 | 
						|
        self.add_input('LnxBoolSocket', 'Keep Transform', default_value = True)
 | 
						|
        self.add_input('LnxBoolSocket', 'Parent Inverse')
 | 
						|
 | 
						|
        self.add_output('LnxNodeSocketAction', 'Out')
 | 
						|
 | 
						|
    def get_replacement_node(self, node_tree: bpy.types.NodeTree):
 | 
						|
        if self.lnx_version not in (0, 1):
 | 
						|
            raise LookupError()
 | 
						|
            
 | 
						|
        return NodeReplacement(
 | 
						|
            'LNSetParentNode', self.lnx_version, 'LNSetParentNode', 2,
 | 
						|
            in_socket_mapping={0:0, 1:1, 2:2}, out_socket_mapping={0:0}
 | 
						|
        )
 |