Move Anim_Setup
module into Blender_Kitsu
#5
@ -64,7 +64,6 @@ class TransferCollectionTriplet:
|
|||||||
continue
|
continue
|
||||||
util.reset_armature_pose(
|
util.reset_armature_pose(
|
||||||
ob,
|
ob,
|
||||||
only_selected=False,
|
|
||||||
reset_properties=True,
|
reset_properties=True,
|
||||||
reset_transforms=True,
|
reset_transforms=True,
|
||||||
)
|
)
|
||||||
|
@ -77,6 +77,7 @@ class TaskLayer:
|
|||||||
cls.transfer_collections(transfer_mapping)
|
cls.transfer_collections(transfer_mapping)
|
||||||
cls.transfer_data(context, build_context, transfer_mapping, transfer_settings)
|
cls.transfer_data(context, build_context, transfer_mapping, transfer_settings)
|
||||||
cls.assign_objects(transfer_mapping)
|
cls.assign_objects(transfer_mapping)
|
||||||
|
cls.fix_geonode_modifiers()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def transfer_data(
|
def transfer_data(
|
||||||
@ -256,6 +257,16 @@ class TaskLayer:
|
|||||||
coll.objects.link(tgt_ob)
|
coll.objects.link(tgt_ob)
|
||||||
ob.user_remap(tgt_ob)
|
ob.user_remap(tgt_ob)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def fix_geonode_modifiers(cls):
|
||||||
|
"""Workaround to a weird issue where some GeoNode modifier inputs disappear..."""
|
||||||
|
for o in bpy.data.objects:
|
||||||
|
if o.type != 'MESH':
|
||||||
|
continue
|
||||||
|
for m in o.modifiers:
|
||||||
|
if m.type == 'NODES':
|
||||||
|
m.node_group = m.node_group
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f"TaskLayer{self.name}"
|
return f"TaskLayer{self.name}"
|
||||||
|
|
||||||
|
@ -79,52 +79,39 @@ def is_addon_active(module_name, context=None):
|
|||||||
|
|
||||||
def reset_armature_pose(
|
def reset_armature_pose(
|
||||||
rig: bpy.types.Object,
|
rig: bpy.types.Object,
|
||||||
only_selected=False,
|
|
||||||
reset_transforms=True,
|
reset_transforms=True,
|
||||||
reset_properties=True,
|
reset_properties=True,
|
||||||
):
|
):
|
||||||
bones = rig.pose.bones
|
bones = rig.pose.bones
|
||||||
if only_selected:
|
|
||||||
bones = [pb for pb in rig.pose.bones if pb.bone.select]
|
|
||||||
|
|
||||||
for pb in bones:
|
for pb in bones:
|
||||||
if reset_transforms:
|
if reset_transforms:
|
||||||
pb.location = (0, 0, 0)
|
pb.location = ((0, 0, 0))
|
||||||
pb.rotation_euler = (0, 0, 0)
|
pb.rotation_euler = ((0, 0, 0))
|
||||||
pb.rotation_quaternion = (1, 0, 0, 0)
|
pb.rotation_quaternion = ((1, 0, 0, 0))
|
||||||
pb.scale = (1, 1, 1)
|
pb.scale = ((1, 1, 1))
|
||||||
|
|
||||||
if reset_properties and len(pb.keys()) > 0:
|
if reset_properties and len(pb.keys()) > 0:
|
||||||
rna_properties = [
|
rna_properties = [prop.identifier for prop in pb.bl_rna.properties if prop.is_runtime]
|
||||||
prop.identifier for prop in pb.bl_rna.properties if prop.is_runtime
|
|
||||||
]
|
|
||||||
|
|
||||||
# Reset custom property values to their default value
|
# Reset custom property values to their default value
|
||||||
for key in pb.keys():
|
for key in pb.keys():
|
||||||
if key.startswith("$"):
|
if key.startswith("$"): continue
|
||||||
continue
|
if key in rna_properties: continue # Addon defined property.
|
||||||
if key in rna_properties:
|
|
||||||
continue # Addon defined property.
|
|
||||||
|
|
||||||
ui_data = None
|
ui_data = None
|
||||||
try:
|
try:
|
||||||
ui_data = pb.id_properties_ui(key)
|
ui_data = pb.id_properties_ui(key)
|
||||||
if not ui_data:
|
if not ui_data: continue
|
||||||
continue
|
|
||||||
ui_data = ui_data.as_dict()
|
ui_data = ui_data.as_dict()
|
||||||
if not "default" in ui_data:
|
if not 'default' in ui_data: continue
|
||||||
continue
|
|
||||||
except TypeError:
|
except TypeError:
|
||||||
# Some properties don't support UI data, and so don't have a
|
# Some properties don't support UI data, and so don't have a default value. (like addon PropertyGroups)
|
||||||
# default value. (like addon PropertyGroups)
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if not ui_data:
|
if not ui_data: continue
|
||||||
continue
|
|
||||||
|
|
||||||
if type(pb[key]) not in (float, int):
|
if type(pb[key]) not in (float, int, bool): continue
|
||||||
continue
|
pb[key] = ui_data['default']
|
||||||
pb[key] = ui_data["default"]
|
|
||||||
|
|
||||||
|
|
||||||
ID_INFO = {
|
ID_INFO = {
|
||||||
|
Loading…
Reference in New Issue
Block a user