def modelProxy(): s = bpy.context.scene ao = bpy.context.active_object if utils.is_linked_asset(ao): utils.activate(ao) g = ao.instance_collection rigs = [] for ob in g.objects: if ob.type == 'ARMATURE': rigs.append(ob) if len(rigs) == 1: ao.instance_collection = None bpy.ops.object.duplicate() new_ao = bpy.context.view_layer.objects.active new_ao.instance_collection = g new_ao.empty_display_type = 'SPHERE' new_ao.empty_display_size *= 0.1 bpy.ops.object.proxy_make(object=rigs[0].name) proxy = bpy.context.active_object bpy.context.view_layer.objects.active = ao ao.select_set(True) new_ao.select_set(True) new_ao.use_extra_recalc_object = True new_ao.use_extra_recalc_data = True bpy.ops.object.parent_set(type='OBJECT', keep_transform=True) return True else: # TODO report this to ui print('not sure what to proxify') return False
colmapdict = { 'BALL': 'Ball', 'BALL_COMPLEX': 'Ball complex', 'FLUID': 'Fluid', 'CLOTH': 'Cloth', 'HAIR': 'Hair' } unhide_collection(colmapdict[data["thumbnail_type"]]) if data['thumbnail_background']: unhide_collection('Background') bpy.data.materials["bg checker colorable"].node_tree.nodes['input_level'].outputs['Value'].default_value \ = data['thumbnail_background_lightness'] tscale = data["thumbnail_scale"] scaler = bpy.context.view_layer.objects['scaler'] scaler.scale = (tscale, tscale, tscale) utils.activate(scaler) bpy.ops.object.transform_apply(location=False, rotation=False, scale=True) bpy.context.view_layer.update() for ob in bpy.context.visible_objects: if ob.name[:15] == 'MaterialPreview': utils.activate(ob) bpy.ops.object.transform_apply(location=False, rotation=False, scale=True) ob.material_slots[0].material = mat ob.data.use_auto_texspace = False