STEP: open/insert/drag-drop

Import base feature (FeatureKind::Import, timeline type BaseFeature) holding
the STEP text and the file's product tree; bodies named from the file.
doc.open accepts .step/.stp (any case) as a new design; Insert STEP
(FusionImportCommandFromToolbar) adds one to the current design; File menu,
SOLID > INSERT, drag-and-drop (insert into a non-empty design, else open),
'solvecraft part.step', MCP open. Features (fillet, hole, sketch-on-face
cut, shell) work on imported bodies. Imports are cached so a file is read
once per command. Measure tightens its chord tolerance for small radii.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AS5Tn3xieewUSg3uxrMVdL
This commit is contained in:
bherbruckandClaude Opus 5.5 committed 2026-10-07 21:01:04 +00:00
1 parent ed611ed7ba
commit f3dbb12b23
18 files changed
+360 -18

No files matched your search

+26
View File
@@ -567,6 +567,32 @@ impl<'a> Reader<'a> {
}
}
/// Recent imports, so a file read for a command and then evaluated in the timeline is only
/// read once.
static RECENT: std::sync::Mutex<Vec<(u64, usize, std::sync::Arc<StepImport>)>> = std::sync::Mutex::new(Vec::new());
/// [`step_import`] through a small cache of recent results (keyed by the text).
pub fn step_import_shared(text: &str) -> Result<std::sync::Arc<StepImport>> {
use std::hash::{Hash, Hasher};
let mut h = std::collections::hash_map::DefaultHasher::new();
text.hash(&mut h);
let key = (h.finish(), text.len());
if let Ok(cache) = RECENT.lock()
&& let Some((_, _, imp)) = cache.iter().find(|(k, n, _)| (*k, *n) == key)
{
return Ok(imp.clone());
}
let imp = std::sync::Arc::new(step_import(text)?);
if let Ok(mut cache) = RECENT.lock() {
cache.retain(|(k, n, _)| (*k, *n) != key);
cache.push((key.0, key.1, imp.clone()));
if cache.len() > 4 {
cache.remove(0);
}
}
Ok(imp)
}
/// Read a STEP file: its solids (as bodies, placed by the assembly structure) and the tree.
pub fn step_import(text: &str) -> Result<StepImport> {
let ex = p21::parse(text).map_err(KernelError::Invalid)?;