fix: enforce Revit roof views and orphan geometry gates
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
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:
@@ -244,6 +244,23 @@ def match_patterns(value: str, patterns: list[str]) -> bool:
|
||||
return any(fnmatch.fnmatch(upper_value, str(pattern).upper()) for pattern in patterns)
|
||||
|
||||
|
||||
def block_matches_floor(block_name: str, floor: dict[str, Any], drawing: dict[str, Any]) -> bool:
|
||||
"""Apply source-view block selectors before expanding a Revit sheet.
|
||||
|
||||
Revit DXF exports can place several views at identical world coordinates;
|
||||
their top-level INSERT names retain the view suffix (for example
|
||||
``-屋面平面图`` vs ``-机房小屋面``). A clip cannot separate those views, so
|
||||
the floor config must be able to select the corresponding block family.
|
||||
"""
|
||||
includes = list(floor.get("include_block_names", drawing.get("include_block_names", [])) or [])
|
||||
excludes = list(floor.get("exclude_block_names", drawing.get("exclude_block_names", [])) or [])
|
||||
if includes and (not block_name or not match_patterns(block_name, includes)):
|
||||
return False
|
||||
if excludes and block_name and match_patterns(block_name, excludes):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def block_category(block_name: str, config: dict[str, Any]) -> str | None:
|
||||
for category, patterns in config.get("block_name_categories", {}).items():
|
||||
if match_patterns(block_name, list(patterns)):
|
||||
@@ -527,6 +544,12 @@ def collect_raw_segments(
|
||||
ignored_by_type: dict[str, int] = defaultdict(int)
|
||||
|
||||
for entity in entities:
|
||||
root_block_name = (
|
||||
str(entity.dxf.name) if entity.dxftype() == "INSERT" and entity.dxf.hasattr("name") else ""
|
||||
)
|
||||
eligible_floors = [item for item in floor_specs if block_matches_floor(root_block_name, item[0], drawing)]
|
||||
if not eligible_floors:
|
||||
continue
|
||||
for extracted_entity, fallback_layer, block_name in iter_model_entities(entity, config):
|
||||
layer = entity_layer(extracted_entity)
|
||||
category = category_for_entity(
|
||||
@@ -547,7 +570,7 @@ def collect_raw_segments(
|
||||
min_source = min_source_by_category.get(category, min_source_length)
|
||||
min_meters = min_meters_by_category.get(category, min_meters_length)
|
||||
for start, end in segments:
|
||||
for floor, key, offset in floor_specs:
|
||||
for floor, key, offset in eligible_floors:
|
||||
if not segment_matches_floor(start, end, floor, drawing):
|
||||
continue
|
||||
trimmed = clip_segment_to_rect(start, end, floor.get("clip", drawing.get("clip")))
|
||||
|
||||
Reference in New Issue
Block a user