diff --git a/Cargo.lock b/Cargo.lock index 421e740c..cdfab1d4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 4 [[package]] name = "H7CAD" -version = "0.1.3" +version = "0.1.4" dependencies = [ "acadrust", "bytemuck", diff --git a/Cargo.toml b/Cargo.toml index eeaaafc3..31433981 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "H7CAD" -version = "0.1.3" +version = "0.1.4" edition = "2021" build = "build.rs" diff --git a/src/scene/mod.rs b/src/scene/mod.rs index e512bff7..7024c072 100644 --- a/src/scene/mod.rs +++ b/src/scene/mod.rs @@ -429,11 +429,6 @@ impl Scene { } /// Decide whether an entity should be drawn as direct content of `block_handle`. - /// - /// Normal case: entity.owner_handle equals the active layout/model block. - /// Fallback: if owner is null, allow it only when the handle is not listed - /// under any other block record. This prevents block-definition geometry - /// from leaking into the viewport when malformed files omit owner handles. fn belongs_to_visible_block( &self, entity_handle: Handle, @@ -450,6 +445,17 @@ impl Scene { return false; } + // owner_handle is null (common in DXF files that omit group code 330). + // Use the current layout's entity_handles as the authoritative list when + // available — this prevents block-definition geometry from leaking into + // the viewport even when owner handles are missing. + if let Some(br) = self.document.block_records.iter().find(|br| br.handle == block_handle) { + if !br.entity_handles.is_empty() { + return br.entity_handles.contains(&entity_handle); + } + } + + // entity_handles not populated: fall back to "not listed in any other block". !self .document .block_records