×

OmniGraffle: Canvas to Clipboard to Craft

This Omni Automation plug-in for OmniGraffle “prints” the current canvas to the clipboard in PNG image format, and provides an option to switch to the Craft application for pasting into a document.

NOTE: The current PNG export settings for background transparency are used in the generation of the PNG image.

Canvas to Clipboard to Craft
Export the current canvas to the clipboard in PNG image format, with an option to switch to the Craft application for pasting into a document.

Return to: Omni Automation and Craft

Canvas to Clipboard to Craft
 

/*{ "type": "action", "targets": ["omnigraffle"], "author": "Otto Automator", "identifier": "com.omni-automation.og.canvas-to-clipboard-image", "version": "1.1", "description": "Puts an image of the current canvas on the clipboard using the current PNG export settings.", "label": "Canvas to Clipboard Image", "shortLabel": "Canvas to Clipboard Image", "paletteLabel": "Canvas to Clipboard Image", "image": "gearshape" }*/ (() => { var action = new PlugIn.Action(async function(selection, sender){ // action code // selection options: canvas, document, graphics, lines, solids, view cnvs = document.windows[0].selection.canvas exportName = cnvs.name + ".png" fileTypeID = "public.png" wrapper = await document.makeFileWrapper(exportName, fileTypeID) item = new Pasteboard.Item() item.setDataForType(wrapper.contents,TypeIdentifier.png) Pasteboard.general.clear() Pasteboard.general.addItems([item]) alertTitle = "Completed" alertMessage = "An image of the current canvas is on the clipboard." alert = new Alert(alertTitle,alertMessage) alert.addOption("Done") alert.addOption("Craft") buttonIndex = await alert.show() if (buttonIndex === 1){ URL.fromString("craftdocs://").open() } }); action.validate = function(selection, sender){ // validation code // selection options: canvas, document, graphics, lines, solids, view return true }; return action; })();