Skip to main content
100%

Read/Write Sketch objects from the pasteboard

✓ Published0🌍 Public
KKevinGutowski
Last edited May 20, 2021
Created on May 20, 2021

This example demonstrates how to copy and paste Sketch layer objects through the system pasteboard, showing both read and write operations. The read script retrieves layers from the pasteboard using `MSPasteboardManager.readPasteboardLayersFromPasteboard` and wraps them with the Sketch JavaScript API. The write script takes a selected layer from `doc.selectedLayers`, wraps it in an `MSLayerArray`, and writes it using `MSPasteboardLayers.pasteboardLayersWithLayers` and `MSPasteboardManager.writePasteboardLayers_toPasteboard`. The code relies on the `sketch` module and native Objective-C class access, with `context.document` providing the document’s color space.

AI-generated description

Similar vizzes