fix: distinguish Revit view wrappers from family blocks
Some checks failed
ci / test (macos-latest, 3.10) (push) Has been cancelled
ci / test (macos-latest, 3.12) (push) Has been cancelled
ci / test (ubuntu-latest, 3.10) (push) Has been cancelled
ci / test (ubuntu-latest, 3.12) (push) Has been cancelled
ci / test (windows-latest, 3.10) (push) Has been cancelled
ci / test (windows-latest, 3.12) (push) Has been cancelled
ci / browser-smoke (push) Has been cancelled

This commit is contained in:
2026-07-21 14:38:30 +08:00
parent 20ef26db9f
commit e0cd974c6b
2 changed files with 22 additions and 11 deletions

View File

@@ -718,7 +718,12 @@ def main() -> int:
"layer": "INSERT_NAME",
"_clip_hint": clip_hint,
"_preserve_component_union": key in preserve_component_union_keys,
"_include_block_names": [f"*-{label}"],
# Only a small number of large top-level view wrappers can be
# used as root INSERT selectors. Repeated family/component
# blocks also end in the view name in many Revit exports; using
# their suffix as a root filter drops unrelated wall/column
# INSERTs from the same floor.
**({"_include_block_names": [f"*-{label}"]} if 1 <= len(points) <= 3 and len(expanded) >= 50 else {}),
}
)

View File

@@ -210,16 +210,17 @@ def make_revit_overlapping_roof_dxf(path: Path) -> None:
for layer in ("I-WALL", "S-GRID", "A-DOOR"):
doc.layers.add(layer)
msp = doc.modelspace()
for i in range(12):
x = 4000.0 * i
msp.add_line((x, 0), (x, 24000), dxfattribs={"layer": "I-WALL"})
for y in (0, 8000, 16000, 24000):
msp.add_line((0, y), (44000, y), dxfattribs={"layer": "S-GRID"})
for title in ("屋面平面图", "机房小屋面"):
block = doc.blocks.new(name=f"屋面构件-{title}")
block.add_line((0, 0), (900, 0), dxfattribs={"layer": "A-DOOR"})
for i in range(12):
msp.add_blockref(block.name, (4000.0 * i, 2000.0 * (i % 10)))
for index, title in enumerate(("屋面平面图", "机房小屋面"), start=1):
# True view wrapper: one large root INSERT carries the whole plan. This
# is intentionally different from repeated family blocks whose names
# also end in a floor title.
block = doc.blocks.new(name=f"NY-ARCH_rvt-{index}-{title}")
for i in range(55):
x = 800.0 * i
block.add_line((x, 0), (x, 24000), dxfattribs={"layer": "I-WALL"})
for y in (0, 4000, 8000, 12000, 16000, 20000, 24000):
block.add_line((0, y), (43200, y), dxfattribs={"layer": "S-GRID"})
msp.add_blockref(block.name, (0, 0))
doc.saveas(path)
@@ -870,6 +871,11 @@ def main() -> int:
revit_clips = {f["key"]: f["clip"] for f in revit_floors}
separated = revit_clips.get("F1", [0, 0, 0, 0])[2] < revit_clips.get("F2", [0, 0, 0, 0])[0]
check("Revit INSERT-name clips stay spatially separated", separated, str(revit_clips))
check(
"repeated Revit family suffixes do not become root selectors",
all("include_block_names" not in floor for floor in revit_floors),
str(revit_floors),
)
roof_path = revit_dir / "A212 - 主楼屋顶平面图.dxf"
make_revit_overlapping_roof_dxf(roof_path)