import bpy,os
from mathutils import Vector
ROOT='/root/fal-author/le-mans-prototype-v1'
bpy.ops.wm.open_mainfile(filepath=ROOT+'/source.blend')
for o in list(bpy.data.objects):
 if o.name in ('Body','SteeringWheel','Wheel_FL','Wheel_FR','Wheel_RL','Wheel_RR') or o.type=='EMPTY':bpy.data.objects.remove(o,do_unlink=True)
for group in list(bpy.data.node_groups):
 if group.name.startswith('glTF Material Output'):bpy.data.node_groups.remove(group,do_unlink=True)
bpy.ops.import_scene.gltf(filepath=ROOT+'/le-mans-prototype.glb')
s=bpy.context.scene;s.render.engine='CYCLES';s.cycles.device='GPU';s.cycles.samples=24
p=bpy.context.preferences.addons['cycles'].preferences;p.compute_device_type='OPTIX';p.get_devices()
for d in p.devices:d.use=d.type!='CPU'
s.render.resolution_x=1280;s.render.resolution_y=720;s.render.filepath=ROOT+'/export-check.png';bpy.ops.render.render(write_still=True)
print('EXPORT_REIMPORT_RENDER_OK')
