Skip to content

Instantly share code, notes, and snippets.

Created January 26, 2016 10:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
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)
for node in Path.nodes:
if "components" in Dictionary:
Elements = Dictionary["components"]
for currComponentDict in Elements:
component = GSComponent.alloc().initWithElementDict_(currComponentDict)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment