forked from 1b-agent/opencadstudio-upstream
Complete Ole2Frame: embed a picture file from a script
EmbedPicture builds the frame with OCS's own EmbeddedImage and build_embedded_ole, so the opaque storage is never scripted. PNG, JPEG and BMP are stored as read and other formats are re-encoded as PNG. The lifecycle test now creates through Python; a new test covers formats, aspect, origin, layer and refusals. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
1 parent
942222c381
commit
5e6a830782
8 files changed
+148
-7
No files matched your search
@@ -220,6 +220,13 @@ class _Document:
|
||||
handle = entity.handle if isinstance(entity, _Entity) else int(entity)
|
||||
ocs.remove_entity(handle)
|
||||
|
||||
def embed_picture(self, path, origin=(0, 0, 0), width=1, layer=None):
|
||||
"""Embed a picture file (PNG, JPEG, BMP or another format re-encoded as
|
||||
PNG) as an OLE frame. `origin` is the bottom-left corner and `width`
|
||||
the frame width; the height follows the picture's aspect ratio."""
|
||||
handle = ocs.embed_picture(str(path), [float(v) for v in origin], float(width), layer)
|
||||
return self.entities[handle]
|
||||
|
||||
def coverage(self, kind=None):
|
||||
if kind is not None:
|
||||
return ocs.entity_coverage(kind)
|
||||
|
||||
Reference in new issue
Block a user