forked from 1b-agent/opencadstudio-upstream
fix(properties): name AEC / proxy objects instead of "Unknown"
Selecting a proxy object we render from its cached graphics (an AEC
Wall/Door/Window and the like) showed "Unknown" as its type. The entity
now carries its real DXF class name from the CLASSES section (acadrust
bump), so surface it: ui_name_or_class title-cases the class ("AEC_WALL"
→ "Aec Wall") for the properties Type row and the status-bar label, and
still says "Unknown" only when the class truly can't be named.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
8fd03e56ff
commit
0e61836e91
4 files changed
+31
-3
No files matched your search
Generated
+1
-1
@@ -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",
|
||||
|
||||
+1
-1
@@ -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 {
|
||||
|
||||
@@ -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_<n>` 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::<String>() + &c.as_str().to_lowercase()
|
||||
}
|
||||
None => String::new(),
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.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".
|
||||
|
||||
Vendored
+1
-1
@@ -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()),
|
||||
}],
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user