I am working on a file format importer with the folks over at Mcneel and I would like to handle unit conversion on import. So far so good everything is working well and I can manage to scale the objects however when i attempt to apply the transformation I am running into errors. It seems my object is not currently in the view layer. Any help would be greatly appreciated.
blender_object.scale = scale_factor
bpy.ops.object.select_all(action='DESELECT')
if(blender_object.select_get() is False):
blender_object.select_set(True)
bpy.context.view_layer.objects.active = blender_object
bpy.ops.object.transform_apply(location = False, scale = True, rotation = False)
bpy.ops.object.select_all(action='DESELECT')
Joel