50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
# ***** BEGIN GPL LICENSE BLOCK *****
|
|
#
|
|
# Copyright (C) 2024 Ilia Kurochkin <brothermechanic@yandex.com>
|
|
#
|
|
# Created by Ilia Kurochkin (brothermechanic)
|
|
# contact: brothermechanic@yandex.com
|
|
#
|
|
# This is free software;
|
|
# you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License
|
|
# as published by the Free Software Foundation; either version 3
|
|
# of the License, or (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, see <https://www.gnu.org/licenses/>.
|
|
#
|
|
# ***** END GPL LICENSE BLOCK *****
|
|
#
|
|
# coding: utf-8
|
|
'''
|
|
DESCRIPTION.
|
|
Blender object relations functions.
|
|
'''
|
|
|
|
__version__ = '0.1'
|
|
|
|
import bpy
|
|
|
|
|
|
def parenting(parent, child):
|
|
''' Parenting child object to parent object. '''
|
|
child.parent = parent
|
|
child.matrix_parent_inverse = parent.matrix_world.inverted()
|
|
return child
|
|
|
|
|
|
def unparenting(child):
|
|
''' Unarenting child object from parent object. '''
|
|
# update database
|
|
bpy.context.view_layer.update()
|
|
|
|
world_matrix = child.matrix_world.copy()
|
|
child.parent = None
|
|
child.matrix_world = world_matrix
|
|
return child
|