feat(properties): resolve Hyperlink (XDATA) and custom Material name
Fill the two placeholder rows added earlier. Read the General group's Hyperlink from the entity's XDATA (the "PE_URL" application record's first string). When an entity carries an explicit material (material_flags == 3), resolve its material_handle to the Material object's name and show it in the 3D Visualization group instead of "Custom". Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
1f2d543755
commit
41f4a062dc
2 changed files with 46 additions and 1 deletions
|
|
@ -74,6 +74,39 @@ impl OpenCADStudio {
|
|||
let mut sections =
|
||||
dispatch::properties_sectioned(handle, entity, &text_style_names);
|
||||
|
||||
// Resolve a custom material handle (material_flags == 3) to
|
||||
// its name in the 3D Visualization group.
|
||||
{
|
||||
let common = entity.common();
|
||||
if common.material_flags == 3 {
|
||||
if let Some(mh) = common.material_handle {
|
||||
if let Some(name) = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.objects
|
||||
.iter()
|
||||
.find_map(|(h, o)| match o {
|
||||
acadrust::objects::ObjectType::Material(m) if *h == mh => {
|
||||
Some(m.name.clone())
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
{
|
||||
for section in sections.iter_mut() {
|
||||
if let Some(row) =
|
||||
section.props.iter_mut().find(|p| p.field == "material")
|
||||
{
|
||||
row.value =
|
||||
crate::scene::model::object::PropValue::ReadOnly(
|
||||
name.clone(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Inject viewport-only properties that require doc access.
|
||||
if let acadrust::EntityType::Viewport(vp) = entity {
|
||||
let frozen_names: Vec<String> = vp
|
||||
|
|
|
|||
14
src/scene/cache/properties.rs
vendored
14
src/scene/cache/properties.rs
vendored
|
|
@ -11,6 +11,18 @@ pub fn general_section(entity: &EntityType) -> PropSection {
|
|||
};
|
||||
let transp_pct = (common.transparency.alpha() as f64 / 255.0 * 100.0).round() as u32;
|
||||
|
||||
// Hyperlink is stored in XDATA under the "PE_URL" application.
|
||||
let hyperlink = common
|
||||
.extended_data
|
||||
.get_record("PE_URL")
|
||||
.and_then(|r| {
|
||||
r.values.iter().find_map(|v| match v {
|
||||
acadrust::xdata::XDataValue::String(s) if !s.is_empty() => Some(s.clone()),
|
||||
_ => None,
|
||||
})
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
||||
PropSection {
|
||||
title: "General".into(),
|
||||
props: vec![
|
||||
|
|
@ -64,7 +76,7 @@ pub fn general_section(entity: &EntityType) -> PropSection {
|
|||
Property {
|
||||
label: "Hyperlink".into(),
|
||||
field: "hyperlink",
|
||||
value: PropValue::ReadOnly(String::new()),
|
||||
value: PropValue::ReadOnly(hyperlink),
|
||||
},
|
||||
Property {
|
||||
label: "Invisible".into(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue