Script to scale objects resets scale when scrubbing through frames I am writing a Python script for Blender 2.8 in which I replace objects in the scene with new objects. 
I start by importing the new object as a .FBX and linking the original object data to the new object.
The new object then needs to be scaled down to fit where the old objects were.

The issue is that when I run the script it appears to have worked until I change the animation frame and the scaling I have applied is erased.
Here is a snippet of the code

import bpy

file = '\\Fruit&amp;Veg\\Banana_FBX\\Banana.FBX'
i = file.rfind('\\')
new_asset_name = file[i + 1:-4]
bpy.ops.import_scene.fbx(filepath=file)
bpy.context.view_layer.objects.active = bpy.data.objects[new_asset_name]
bpy.ops.object.scale_clear()

bpy.data.object['Orange'].select_set(True)
bpy.ops.object.make_links_data(type='OBDATA')
bpy.context.view_layer.objects.active = obj

ratio = bpy.data.objects[new_asset_name].dimensions[2] / 0.255 # how much larger new object is

bpy.ops.transform.resize(value=(1/ratio,1/ratio, 1/ratio), orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(False, False, True), mirror=True, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False, release_confirm=True)
I'm pretty sure your scale is keyframed. Just like when you scale manually and there are scale keyframes present, it will ignore your changes (unless you use auto-keying) and reset to the scale saved in the keyframe. FBX often have everything keyed by default export options of the program they were created with, even if the property isn't animated. If that's not the case, please don't downvote, but provide more detail, maybe share the .blend. Thank you.