diff --git a/Cargo.lock b/Cargo.lock index bd0d2f077..ae2e85cc1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,7 +74,7 @@ checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618" [[package]] name = "acadrust" version = "0.4.0" -source = "git+https://github.com/OpenAEC-Foundation/acadifc?branch=main#5fd406fad15d5be2c49f3d8fb8a68dc89b5b5cd3" +source = "git+https://github.com/OpenAEC-Foundation/acadifc?branch=main#2e63e7053f0f245004b41c4b576a0529748f3f41" dependencies = [ "ahash 0.8.12", "anyhow", diff --git a/src/app/helpers.rs b/src/app/helpers.rs index 1a7aaf2e5..4e30d0685 100644 --- a/src/app/helpers.rs +++ b/src/app/helpers.rs @@ -333,7 +333,7 @@ pub(super) fn next_group_auto_name(scene: &crate::scene::Scene) -> String { // ── Entity type labels ───────────────────────────────────────────────────── pub(super) fn entity_type_label(entity: &acadrust::EntityType) -> String { - crate::entities::names::ui_name(entity).to_string() + crate::entities::names::ui_name_or_class(entity) } pub(super) fn entity_type_key(entity: &acadrust::EntityType) -> String { diff --git a/src/entities/names.rs b/src/entities/names.rs index ac84abfed..bfcedd827 100644 --- a/src/entities/names.rs +++ b/src/entities/names.rs @@ -62,6 +62,34 @@ pub fn ui_name(e: &EntityType) -> &'static str { } } +/// Display name that reports an Unknown/proxy entity's real class instead of +/// the generic "Unknown" — an AEC object (Wall/Door/Window etc.) carries its +/// DXF class name (e.g. "AEC_WALL") title-cased to "Aec Wall". Everything else +/// defers to [`ui_name`]. Falls back to "Unknown" for a class we couldn't name +/// (the numeric `DWG_TYPE_` placeholder). +pub fn ui_name_or_class(e: &EntityType) -> String { + if let EntityType::Unknown(u) = e { + let n = u.dxf_name.trim(); + if !n.is_empty() && !n.starts_with("DWG_TYPE_") { + return n + .split('_') + .filter(|w| !w.is_empty()) + .map(|w| { + let mut c = w.chars(); + match c.next() { + Some(f) => { + f.to_uppercase().collect::() + &c.as_str().to_lowercase() + } + None => String::new(), + } + }) + .collect::>() + .join(" "); + } + } + ui_name(e).to_string() +} + /// Canonical DXF entity type record name (uppercase), as used by AutoCAD's /// command-line LIST output and the DXF file format. Variants without a /// well-defined DXF name fall back to "ENTITY". diff --git a/src/scene/cache/properties.rs b/src/scene/cache/properties.rs index 8f7d4c1b5..86391fba0 100644 --- a/src/scene/cache/properties.rs +++ b/src/scene/cache/properties.rs @@ -140,7 +140,7 @@ pub fn fallback_properties(_handle: Handle, entity: &EntityType) -> PropSection props: vec![Property { label: "Type".into(), field: "type", - value: PropValue::ReadOnly(crate::entities::names::ui_name(entity).into()), + value: PropValue::ReadOnly(crate::entities::names::ui_name_or_class(entity).into()), }], } }