"""Critique 2: what happens when the README's append steps are done in a file that has its own doors (the ship). A new empty file gets two stand-in doors named like the ship's, then the README's collections are appended from DoorRobotArm.blend. Where do the drivers point afterwards? Nothing is saved. blender -b --factory-startup --python previews/critique2/crit2_append_test.py -- """ import json import os import sys import bpy OUT = sys.argv[sys.argv.index("--") + 1] HERE = os.path.dirname(os.path.abspath(__file__)) SRC = os.path.join(os.path.dirname(os.path.dirname(HERE)), "DoorRobotArm.blend") bpy.ops.wm.read_factory_settings(use_empty=True) sc = bpy.context.scene for n in ("Moonpool_Door_Aft", "Moonpool_Door_Fore"): o = bpy.data.objects.new(n, None) # the ship's own doors (stand-ins) sc.collection.objects.link(o) want = ["DoorArm | version A", "DoorArm | version B", "DoorArm | rail kit", "DoorArm | solver (hidden)", "DoorArm | controls"] with bpy.data.libraries.load(SRC, link=False) as (src, dst): dst.collections = [c for c in src.collections if c in want] for c in dst.collections: if c is not None: sc.collection.children.link(c) targets = {} for o in bpy.data.objects: ad = o.animation_data if not ad: continue for fc in ad.drivers: for v in fc.driver.variables: for t in v.targets: if t.id is not None and t.id.name.startswith("Moonpool_Door"): targets[t.id.name] = targets.get(t.id.name, 0) + 1 R = {"driver_targets_named_like_doors": targets, "door_objects_now_in_file": sorted(o.name for o in bpy.data.objects if o.name.startswith("Moonpool_Door")), "door_copies_in_a_scene": sorted(o.name for o in bpy.data.objects if o.name.startswith("Moonpool_Door") and o.users_scene), "objects_appended": len(bpy.data.objects)} with open(OUT, "w") as fh: json.dump(R, fh, indent=1) print("[crit2] append test", json.dumps(R), flush=True)