-
Notifications
You must be signed in to change notification settings - Fork 23
/
Paste Background.py
42 lines (34 loc) · 1006 Bytes
/
Paste Background.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#MenuTitle: Paste Background
# encoding: utf-8
# by Tim Ahrens
# http://justanotherfoundry.com
# https://github.com/justanotherfoundry/freemix-glyphsapp
__doc__='''
Pastes the background into the current layer.
Components are pasted as paths (i.e. decomposed).
'''
from GlyphsApp import *
doc = Glyphs.currentDocument
font = doc.font
layers = doc.selectedLayers()
glyph = layers[0].parent
glyph.beginUndo()
for layer in layers:
# deselect all in the foreground
for path in layer.paths:
for node in path.nodes:
layer.removeObjectFromSelection_( node )
# layer.removeObjectsFromSelection_( path.pyobjc_instanceMethods.nodes() )
# insert the background contents and select them
for path in layer.background.copyDecomposedLayer().paths:
layer.paths.append( path.copy() )
# select path
try:
# Glyphs 2
for node in layer.paths[-1].nodes:
layer.addSelection_( node )
except:
# Glyphs 3
for node in layer.shapes[-1].nodes:
layer.addSelection_( node )
glyph.endUndo()