forked from 1b-agent/opencadstudio-upstream
feat(python): validated, undoable layer table (doc.layers)
Adds the additive v7 TableOperation request and HostApi::table_operation for layer create/modify/rename/delete/set-current. Refusals are decided before the undo step is recorded. Python wrapper, real-IPC audit with DWG/DXF persistence, IPC round-trip test, Python unit test and docs. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6b8056cfeb
commit
b7b6e2cef5
12 files changed
+681
No files matched your search
@@ -85,6 +85,25 @@ pub enum SolidBoolean {
|
||||
Intersect,
|
||||
}
|
||||
|
||||
/// A change to a drawing table record (API v7, additive). The host validates
|
||||
/// the request, records one undo step and refuses without changing anything
|
||||
/// when it cannot honour it; the result is the record's handle.
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub enum TableOperation {
|
||||
/// Create a layer. `config.name` must be unused and valid.
|
||||
LayerCreate { config: LayerConfig },
|
||||
/// Change only the properties `config` sets on an existing layer.
|
||||
LayerModify { config: LayerConfig },
|
||||
/// Rename a layer; entities on it follow. Layer `0` and `Defpoints` stay.
|
||||
LayerRename { from: String, to: String },
|
||||
/// Delete a layer. A layer that still holds objects is refused unless
|
||||
/// `erase_objects` is set, which erases them with the layer. Layer `0`,
|
||||
/// `Defpoints` and the current layer are never deleted.
|
||||
LayerDelete { name: String, erase_objects: bool },
|
||||
/// Make an existing layer current.
|
||||
LayerSetCurrent { name: String },
|
||||
}
|
||||
|
||||
/// A kernel operation on ACIS-backed solids (API v7, additive). The host owns
|
||||
/// the geometry: a script never sees or rewrites the payload.
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
@@ -690,6 +709,12 @@ pub trait HostApi {
|
||||
fn solid_operation(&mut self, _operation: SolidOperation) -> Result<Handle, String> {
|
||||
Err("solid operations are not supported by this host".to_owned())
|
||||
}
|
||||
|
||||
/// Create, change, rename, delete or select a drawing table record (API v7,
|
||||
/// additive). Returns the record's handle; a refusal changes nothing.
|
||||
fn table_operation(&mut self, _operation: TableOperation) -> Result<Handle, String> {
|
||||
Err("table operations are not supported by this host".to_owned())
|
||||
}
|
||||
/// Add a layer to the active document with full initial properties.
|
||||
/// If an optional property in `config` is `None`, standard CAD defaults are applied.
|
||||
/// Returns `None` if the layer already exists or `config.name` is invalid.
|
||||
|
||||
Reference in new issue
Block a user