Adopt and restore template transparency for new matching objects

This commit is contained in:
ramox81 committed 2026-09-11 11:10:29 +03:00
1 parent b24feab498
commit 49d1125530
2 files changed
+12 -1

No files matched your search

+11 -1
View File
@@ -1373,6 +1373,7 @@ impl OpenCADStudio {
crate::entities::names::dxf_name(e).to_string(), crate::entities::names::dxf_name(e).to_string(),
c.layer.clone(), c.layer.clone(),
c.color, c.color,
c.transparency,
c.linetype.clone(), c.linetype.clone(),
c.linetype_scale, c.linetype_scale,
c.line_weight, c.line_weight,
@@ -1384,7 +1385,7 @@ impl OpenCADStudio {
}, },
) )
}); });
let Some((verb, kind, layer, color, linetype, lt_scale, lw, template_dimstyle)) = info let Some((verb, kind, layer, color, transparency, linetype, lt_scale, lw, template_dimstyle)) = info
else { else {
self.command_line self.command_line
.push_error(crate::t!("ADDSELECTED: selected object not found.").as_ref()); .push_error(crate::t!("ADDSELECTED: selected object not found.").as_ref());
@@ -1408,6 +1409,7 @@ impl OpenCADStudio {
layer_name: self.tabs[i].scene.document.header.current_layer_name.clone(), layer_name: self.tabs[i].scene.document.header.current_layer_name.clone(),
layer_handle: self.tabs[i].scene.document.header.current_layer_handle, layer_handle: self.tabs[i].scene.document.header.current_layer_handle,
color: self.tabs[i].scene.document.header.current_entity_color, color: self.tabs[i].scene.document.header.current_entity_color,
transparency: self.tabs[i].scene.document.current_entity_transparency(),
linetype_name: self.tabs[i].scene.document.header.current_linetype_name.clone(), linetype_name: self.tabs[i].scene.document.header.current_linetype_name.clone(),
linetype_handle: self.tabs[i].scene.document.header.current_linetype_handle, linetype_handle: self.tabs[i].scene.document.header.current_linetype_handle,
line_weight: self.tabs[i].scene.document.header.current_line_weight, line_weight: self.tabs[i].scene.document.header.current_line_weight,
@@ -1422,6 +1424,11 @@ impl OpenCADStudio {
ribbon_lineweight: self.ribbon.active_lineweight, ribbon_lineweight: self.ribbon.active_lineweight,
}; };
self.add_selected_restore = Some(restore); self.add_selected_restore = Some(restore);
if !self.tabs[i].scene.document.set_current_entity_transparency(transparency) {
self.add_selected_restore = None;
self.command_line.push_error("ADDSELECTED: template transparency cannot be adopted.");
return Task::none();
}
// Adopt the template's general properties as the current defaults. The // Adopt the template's general properties as the current defaults. The
// entity-creation path stamps new objects from the tab's active layer // entity-creation path stamps new objects from the tab's active layer
@@ -1504,6 +1511,9 @@ impl OpenCADStudio {
h.current_dimstyle_name = r.dimstyle_name; h.current_dimstyle_name = r.dimstyle_name;
h.current_dimstyle_handle = r.dimstyle_handle; h.current_dimstyle_handle = r.dimstyle_handle;
} }
if !self.tabs[i].scene.document.set_current_entity_transparency(r.transparency) {
self.command_line.push_error("ADDSELECTED: current transparency could not be restored.");
}
self.tabs[i].active_layer = r.tab_active_layer; self.tabs[i].active_layer = r.tab_active_layer;
self.tabs[i].layers.current_layer = r.tab_layers_current; self.tabs[i].layers.current_layer = r.tab_layers_current;
self.ribbon.active_layer = r.ribbon_layer; self.ribbon.active_layer = r.ribbon_layer;
+1
View File
@@ -307,6 +307,7 @@ struct AddSelectedRestore {
layer_name: String, layer_name: String,
layer_handle: acadrust::types::Handle, layer_handle: acadrust::types::Handle,
color: AcadColor, color: AcadColor,
transparency: acadrust::types::Transparency,
linetype_name: String, linetype_name: String,
linetype_handle: acadrust::types::Handle, linetype_handle: acadrust::types::Handle,
line_weight: i16, line_weight: i16,