forked from 1b-agent/opencadstudio-upstream
feat(python): linetypes and layouts (doc.linetypes, doc.layouts)
TableOperation gains simple-linetype create/modify/rename/delete (standard names taken, rename follows layers and entities, guarded delete) and paper-space layout create/rename/delete/set-current/set-page (default page setup and sheet viewport, the application's own layout switch, Model protected). CTAB now reports the current layout. Real-IPC audit with DWG/DXF persistence and undo, IPC and Python unit tests, docs. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b1edc9f578
commit
795aa922b4
8 files changed
+960
No files matched your search
@@ -147,6 +147,34 @@ pub enum TableOperation {
|
||||
/// new entity's handle. Edit and delete members with the ordinary entity
|
||||
/// operations.
|
||||
BlockEntityAdd { block: String, entity: EntityType },
|
||||
/// Create a simple linetype. `pattern` is signed lengths in drawing units:
|
||||
/// positive is a dash, negative a gap, zero a dot (2-12 elements with at
|
||||
/// least one dash or dot and one gap). Returns the linetype's handle.
|
||||
LinetypeCreate { name: String, description: String, pattern: Vec<f64> },
|
||||
/// Change a simple linetype's description or pattern in place.
|
||||
LinetypeModify { name: String, description: Option<String>, pattern: Option<Vec<f64>> },
|
||||
/// Rename a linetype; layers and entities that use it follow.
|
||||
LinetypeRename { from: String, to: String },
|
||||
/// Delete a linetype that no layer, entity, dimension style or the current
|
||||
/// setting uses. `Continuous`, `ByLayer` and `ByBlock` are never deleted.
|
||||
LinetypeDelete { name: String },
|
||||
/// Create a paper-space layout with the default page setup and sheet viewport.
|
||||
LayoutCreate { name: String },
|
||||
/// Rename a paper-space layout (never `Model`).
|
||||
LayoutRename { from: String, to: String },
|
||||
/// Delete a paper-space layout and everything on it (never `Model`).
|
||||
LayoutDelete { name: String },
|
||||
/// Switch the active layout (`Model` or a paper-space layout).
|
||||
LayoutSetCurrent { name: String },
|
||||
/// Change a paper-space layout's sheet: size in millimetres, rotation in
|
||||
/// degrees (0, 90, 180 or 270) and a custom plot scale (numerator,
|
||||
/// denominator).
|
||||
LayoutSetPage {
|
||||
name: String,
|
||||
paper_size: Option<[f64; 2]>,
|
||||
rotation: Option<u16>,
|
||||
scale: Option<[f64; 2]>,
|
||||
},
|
||||
}
|
||||
|
||||
/// The style tables `TableOperation` can rename, delete or make current.
|
||||
|
||||
@@ -145,6 +145,15 @@ mod tests {
|
||||
block: "C".into(),
|
||||
entity: acadrust::EntityType::Line(acadrust::entities::Line::new()),
|
||||
},
|
||||
TableOperation::LinetypeCreate { name: "L".into(), description: "d".into(), pattern: vec![1.0, -1.0] },
|
||||
TableOperation::LinetypeModify { name: "L".into(), description: None, pattern: Some(vec![2.0, -2.0]) },
|
||||
TableOperation::LinetypeRename { from: "L".into(), to: "M".into() },
|
||||
TableOperation::LinetypeDelete { name: "M".into() },
|
||||
TableOperation::LayoutCreate { name: "S".into() },
|
||||
TableOperation::LayoutRename { from: "S".into(), to: "T".into() },
|
||||
TableOperation::LayoutDelete { name: "T".into() },
|
||||
TableOperation::LayoutSetCurrent { name: "Model".into() },
|
||||
TableOperation::LayoutSetPage { name: "S".into(), paper_size: Some([420.0, 297.0]), rotation: Some(90), scale: Some([1.0, 50.0]) },
|
||||
] {
|
||||
let bytes = bincode::serialize(&PluginRequest::TableOperation { operation: operation.clone() }).unwrap();
|
||||
assert!(matches!(bincode::deserialize::<PluginRequest>(&bytes).unwrap(),
|
||||
|
||||
Reference in new issue
Block a user