Created
August 9, 2019 01:39
-
-
Save weiweihuanghuang/133ec3ed3b1a08ca146e5d062d774986 to your computer and use it in GitHub Desktop.
Set Transform Origin to Centre of Selection.py
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: Set Transform Origin to Centre of Selection | |
# -*- coding: utf-8 -*- | |
__doc__=""" | |
Sets origin point for Rotate tool to the centre of the selection. | |
""" | |
import GlyphsApp | |
Font = Glyphs.font | |
selectedLayer = Font.selectedLayers[0] | |
if len(selectedLayer.selection) > 0: | |
selection = selectedLayer.selectionBounds | |
else: | |
selection = selectedLayer.bounds | |
# selection = selectedLayer.selectionPath().bounds() | |
newOriginX = selection.origin.x + selection.size.width / 2 | |
newOriginY = selection.origin.y + selection.size.height / 2 | |
Glyphs.defaults["GSTransformOriginX"] = newOriginX | |
Glyphs.defaults["GSTransformOriginY"] = newOriginY | |
# Glyphs.redraw() | |
# print newOriginPoint | |
# print selection.origin.x, selection.origin.y, selection.size.width/2, selection.size.height/2 | |
# except Exception, e: | |
# # brings macro window to front and reports error: | |
# Glyphs.showMacroWindow() | |
# print "Set Transform Origin Error: %s" % e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment