forked from 1b-agent/opencadstudio-upstream
feat(python): block definitions (doc.blocks)
TableOperation gains BlockCreate (copy entities into a definition shifted by the base point, optionally erasing originals), BlockModify, BlockRename (inserts follow) and BlockDelete (refused while referenced; removes members, markers and orphaned draw-order tables). Real-IPC audit with DWG/DXF persistence and undo, IPC and Python unit tests, docs; the DXF loss of the block description is pinned by a canary. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
aaea15e4ef
commit
8d20d280fe
9 files changed
+612
No files matched your search
@@ -120,6 +120,28 @@ pub enum TableOperation {
|
||||
StyleDelete { kind: TableStyleKind, name: String },
|
||||
/// Make a text or dimension style current.
|
||||
StyleSetCurrent { kind: TableStyleKind, name: String },
|
||||
/// Define a block from existing drawing entities. The entities are copied
|
||||
/// into the definition shifted by `-base_point` (the block's origin);
|
||||
/// `erase_originals` then removes them from the drawing. No insert is
|
||||
/// placed. Returns the block record's handle.
|
||||
BlockCreate {
|
||||
name: String,
|
||||
entities: Vec<Handle>,
|
||||
base_point: [f64; 3],
|
||||
erase_originals: bool,
|
||||
description: Option<String>,
|
||||
},
|
||||
/// Change a block's description, explodable or uniform-scale settings.
|
||||
BlockModify {
|
||||
name: String,
|
||||
description: Option<String>,
|
||||
explodable: Option<bool>,
|
||||
scale_uniformly: Option<bool>,
|
||||
},
|
||||
/// Rename a block; every insert of it follows.
|
||||
BlockRename { from: String, to: String },
|
||||
/// Delete an unreferenced block definition and its contents.
|
||||
BlockDelete { name: String },
|
||||
}
|
||||
|
||||
/// The style tables `TableOperation` can rename, delete or make current.
|
||||
|
||||
@@ -131,6 +131,16 @@ mod tests {
|
||||
TableOperation::StyleRename { kind: crate::host::TableStyleKind::Text, from: "A".into(), to: "B".into() },
|
||||
TableOperation::StyleDelete { kind: crate::host::TableStyleKind::Dim, name: "A".into() },
|
||||
TableOperation::StyleSetCurrent { kind: crate::host::TableStyleKind::Dim, name: "A".into() },
|
||||
TableOperation::BlockCreate {
|
||||
name: "B".into(),
|
||||
entities: vec![acadrust::Handle::new(4), acadrust::Handle::new(5)],
|
||||
base_point: [1.0, 2.0, 3.0],
|
||||
erase_originals: true,
|
||||
description: Some("d".into()),
|
||||
},
|
||||
TableOperation::BlockModify { name: "B".into(), description: None, explodable: Some(false), scale_uniformly: Some(true) },
|
||||
TableOperation::BlockRename { from: "B".into(), to: "C".into() },
|
||||
TableOperation::BlockDelete { name: "C".into() },
|
||||
] {
|
||||
let bytes = bincode::serialize(&PluginRequest::TableOperation { operation: operation.clone() }).unwrap();
|
||||
assert!(matches!(bincode::deserialize::<PluginRequest>(&bytes).unwrap(),
|
||||
|
||||
Reference in new issue
Block a user