"""Reopen the saved base; change only requested parts and dependent attachments."""
import bpy, sys, hashlib
from pathlib import Path
sys.path.insert(0,str(Path(__file__).resolve().parent))
from build_astra import ROOT, save_export_render

base=ROOT/'fieldnote_r1_base.blend'
bpy.ops.wm.open_mainfile(filepath=str(base))
bpy.context.scene['edit_source_sha256']=hashlib.sha256(base.read_bytes()).hexdigest()
mast=bpy.data.objects['Mast_Column']
# Change mesh coordinates, keeping the bottom fixed. Object-space Z is the mast axis.
for v in mast.data.vertices:v.co.z*=.66/.36
mast.location.z+=.15
head=bpy.data.objects['Mast_Head']
for v in head.data.vertices:v.co.x*=.38/.26
head.location.z+=.30
bpy.data.objects['Mast_Lens'].location.z+=.30
pod=bpy.data.objects['Sample_Pod']
for v in pod.data.vertices:v.co.x*=.66/.46
bpy.data.objects['Sample_Pod_Cap'].location.x+=.10
# Roof owns a separate material: accessory teal stays unchanged.
old=bpy.data.materials['Roof_Teal'];new=old.copy();new.name='Roof_Orange_Edit'
rgb=(.88,.26,.04,1);new.diffuse_color=rgb
new.node_tree.nodes['Principled BSDF'].inputs['Base Color'].default_value=rgb
for o in bpy.context.scene.objects:
    if o.name=='Roof_Panel' or o.name.startswith('Roof_Cell_'):o.data.materials[0]=new
bpy.context.view_layer.update()
save_export_render('edited')
