diff --git a/src/app/properties.rs b/src/app/properties.rs index 6907c4dd0..605fdc8b1 100644 --- a/src/app/properties.rs +++ b/src/app/properties.rs @@ -56,7 +56,7 @@ impl H7CAD { let mut sections = dispatch::properties_sectioned(handle, entity, &text_style_names); - // Inject frozen-layer property for viewports (requires doc access). + // Inject viewport-only properties that require doc access. if let acadrust::EntityType::Viewport(vp) = entity { let frozen_names: Vec = vp .frozen_layers @@ -67,6 +67,21 @@ impl H7CAD { .map(|l| l.name.clone()) }) .collect(); + + // Collect available UCS names for the name picker. + let ucs_names: Vec = self.tabs[i].scene.document.ucss + .iter() + .map(|u| u.name.clone()) + .filter(|n| !n.is_empty()) + .collect(); + + // Current UCS name (resolved from vp.ucs_handle). + let current_ucs = self.tabs[i].scene.document.ucss + .iter() + .find(|u| u.handle == vp.ucs_handle) + .map(|u| u.name.clone()) + .unwrap_or_default(); + if let Some(geom) = sections.last_mut() { geom.props.push(crate::scene::object::Property { label: "Frozen Layers".to_string(), @@ -75,6 +90,16 @@ impl H7CAD { frozen_names.join(", "), ), }); + if !ucs_names.is_empty() { + geom.props.push(crate::scene::object::Property { + label: "UCS Name".to_string(), + field: "vp_ucs_name", + value: crate::scene::object::PropValue::Choice { + selected: current_ucs, + options: ucs_names, + }, + }); + } } } diff --git a/src/app/update.rs b/src/app/update.rs index 79ee2d441..7690e9e70 100644 --- a/src/app/update.rs +++ b/src/app/update.rs @@ -1484,9 +1484,29 @@ impl H7CAD { let handles = self.property_target_handles(i); if !handles.is_empty() { self.push_undo_snapshot(i, "CHPROP"); - for handle in handles { - if let Some(entity) = self.tabs[i].scene.document.get_entity_mut(handle) { - crate::scene::dispatch::apply_geom_prop(entity, field, &value); + if field == "vp_ucs_name" { + // Resolve UCS name → cloned data, then mutate viewports. + let ucs_data = self.tabs[i].scene.document.ucss + .iter() + .find(|u| u.name == value) + .cloned(); + if let Some(ucs) = ucs_data { + for handle in &handles { + if let Some(acadrust::EntityType::Viewport(vp)) = + self.tabs[i].scene.document.get_entity_mut(*handle) + { + vp.ucs_handle = ucs.handle; + vp.ucs_origin = ucs.origin.clone(); + vp.ucs_x_axis = ucs.x_axis.clone(); + vp.ucs_y_axis = ucs.y_axis.clone(); + } + } + } + } else { + for handle in handles { + if let Some(entity) = self.tabs[i].scene.document.get_entity_mut(handle) { + crate::scene::dispatch::apply_geom_prop(entity, field, &value); + } } } self.tabs[i].dirty = true;