Access the Glyphs clipboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#MenuTitle: Clipboard | |
# -*- coding: utf-8 -*- | |
from Foundation import * | |
pasteboard = NSPasteboard.generalPasteboard() | |
typeName = pasteboard.availableTypeFromArray_(["Glyphs elements pasteboard type"]) | |
if typeName == "Glyphs elements pasteboard type": | |
Layer = Glyphs.font.selectedLayers[0] | |
if Layer: | |
Data = pasteboard.dataForType_(typeName) | |
theText = NSString.alloc().initWithData_encoding_(Data, NSUTF8StringEncoding) | |
Dictionary = theText.propertyList() | |
if Dictionary is not None: | |
print Dictionary | |
if "paths" in Dictionary: | |
Elements = Dictionary["paths"] | |
for currPathDict in Elements: | |
Path = GSPath.alloc().initWithPathDict_(currPathDict) | |
Layer.paths.append(Path) | |
for node in Path.nodes: | |
Layer.selection.append(node) | |
if "components" in Dictionary: | |
Elements = Dictionary["components"] | |
for currComponentDict in Elements: | |
component = GSComponent.alloc().initWithElementDict_(currComponentDict) | |
Layer.components.append(component) | |
Layer.selection.append(component) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment