forked from 1b-agent/opencadstudio-upstream
feat(python): block contents (create_entity(..., block=))
BlockEntityAdd adds a validated entity to a block definition (owner set by the host, same validation as a model-space entity, self-nesting inserts refused), reusing the scene's block-editor routing. Deleting a block member now also drops its handle from the block record. Real-IPC audit with an attribute definition inside a block, DWG/DXF persistence and undo; IPC and Python unit tests; docs. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
1 parent
8d20d280fe
commit
b1edc9f578
8 files changed
+251
-7
No files matched your search
@@ -473,11 +473,17 @@ class _Document:
|
||||
def transaction(self, label):
|
||||
return _Transaction(self, label)
|
||||
|
||||
def create_entity(self, kind, **properties):
|
||||
"""Create one mapped entity and return its live document descriptor."""
|
||||
def create_entity(self, kind, block=None, **properties):
|
||||
"""Create one mapped entity and return its live document descriptor.
|
||||
With `block="Name"` the entity is added to that block definition
|
||||
instead of the drawing (its owner is set by the host)."""
|
||||
if "kind" in properties or "handle" in properties:
|
||||
raise ValueError("kind and handle are managed by create_entity")
|
||||
handle = ocs.add(dict(kind=kind, **_coerce_points(kind, properties)))
|
||||
entity = dict(kind=kind, **_coerce_points(kind, properties))
|
||||
if block is not None:
|
||||
handle = ocs.add_to_block(str(block), entity)
|
||||
else:
|
||||
handle = ocs.add(entity)
|
||||
return self.entities[handle]
|
||||
|
||||
def delete_entity(self, entity):
|
||||
|
||||
Reference in new issue
Block a user