Skip to content

Instantly share code, notes, and snippets.

@schriftgestalt
Created January 26, 2016 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schriftgestalt/6ef3dda00264486cb479 to your computer and use it in GitHub Desktop.
Save schriftgestalt/6ef3dda00264486cb479 to your computer and use it in GitHub Desktop.
Access the Glyphs clipboard
#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