here is a script for copy shapes from one glyph and paste to another glyph with same coordinates from left or right
but it didn’t paste selected and copied part, it paste complete source glyph
Is it possible just selected shape paste in glyph or not?
# MenuTitle: Copy & Paste Selected Shapes
# -*- coding: utf-8 -*-
from AppKit import NSPasteboard, NSUTF8StringEncoding
from Foundation import NSString
import GlyphsApp
Glyphs.clearLog()
def paste_shapes_keep_coordinates(measure_from_right=False):
pasteboard = NSPasteboard.generalPasteboard()
typeName = pasteboard.availableTypeFromArray_(["Glyphs elements pasteboard type"])
if typeName == "Glyphs elements pasteboard type":
Data = pasteboard.dataForType_(typeName)
theText = NSString.alloc().initWithData_encoding_(Data, NSUTF8StringEncoding)
Dictionary = theText.propertyList()
if Dictionary is not None:
source_glyph_name = Dictionary['glyph']
source_glyph = Glyphs.font.glyphs[source_glyph_name]
for source_layer in source_glyph.layers:
copied_paths = [path.copy() for path in source_layer.paths]
for sel_layer in Glyphs.font.selectedLayers:
target_layer = sel_layer.parent.layers[source_layer.layerId]
if not target_layer:
continue
for path in copied_paths:
new_path = path.copy()
target_layer.paths.append(new_path)
if measure_from_right:
offset = target_layer.width - source_layer.width
for node in new_path.nodes:
node.x += offset
# Copy shapes and run the script to paste them to all selected layers
paste_shapes_keep_coordinates(measure_from_right=True) # Set to True or False as needed