33 lines
1 KiB
Python
33 lines
1 KiB
Python
# coding: utf-8
|
|
# Copyright (C) 2023 Ilia Kurochkin <brothermechanic@yandex.com>
|
|
#
|
|
# This program 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.
|
|
__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
|