Give new drawings the standard visual styles

A new drawing carries the visual styles the reference's new drawing has
in its visual style dictionary. -VIEW sEttings Visual style offers them
(2dWireframe as "2D Wireframe") and a saved view starts with the 2D
Wireframe style.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
ramox81andClaude Opus 5.5 committed 2026-10-09 17:41:14 +03:00
1 parent 7699c40ae4
commit e3477a27de
4 files changed
+162 -15

No files matched your search

+11 -15
View File
@@ -22,13 +22,7 @@ impl OpenCADStudio {
/// Names -VIEW checks its input against, taken from the drawing.
pub(super) fn dash_view_names(&self, i: usize) -> ViewNames {
let document = &self.tabs[i].scene.document;
let visual_styles: Vec<(String, Handle)> = match document
.objects
.get(&document.header.acad_visualstyle_dict_handle)
{
Some(ObjectType::Dictionary(dictionary)) => dictionary.entries.clone(),
_ => Vec::new(),
};
let visual_styles = crate::io::visual_styles::offered(document);
let live_sections: Vec<(String, Handle)> = document
.entities()
.filter_map(|entity| match entity {
@@ -260,7 +254,15 @@ impl OpenCADStudio {
view.live_section_handle = old.live_section_handle;
view.background_handle = old.background_handle;
}
None => view.handle = document.allocate_handle(),
None => {
view.handle = document.allocate_handle();
if view.visual_style_handle.is_null() {
view.visual_style_handle = crate::io::visual_styles::offered(document)
.into_iter()
.find(|(name, _)| name == "2D Wireframe")
.map_or(Handle::NULL, |(_, handle)| handle);
}
}
}
document.views.add_or_replace(view);
self.tabs[i].dirty = true;
@@ -281,13 +283,7 @@ impl OpenCADStudio {
};
match setting {
"BACKGROUND" => view.background_handle = Handle::NULL,
"VISUALSTYLE" => {
let styles = match document.objects.get(&document.header.acad_visualstyle_dict_handle) {
Some(ObjectType::Dictionary(dictionary)) => dictionary.entries.clone(),
_ => Vec::new(),
};
view.visual_style_handle = find(styles);
}
"VISUALSTYLE" => view.visual_style_handle = find(crate::io::visual_styles::offered(document)),
"SECTION" => {
let sections: Vec<(String, Handle)> = document
.entities()