Scripting to control the Smart Component properties?


I am exploring the scripting side of Glyphapp, and wonder how to control the value of smart properties.

I made the script for controlling the position of a certain component within selected glyphs, and I works fine (attached below). I would like to change this script into controlling smart properties, but I have no clue what command or api I should use for that. I thought “GSComponent Class Reference” this contains the clue, but I was not able to understand 100 percent unfortunately.

Hope I can get some hint for that!

import GlyphsApp

font = Glyphs.font

selected_glyphs = [l.parent for l in font.selectedLayers]

component_name = "component_name"

new_x = 100
new_y = 200

for glyph in selected_glyphs:
    for layer in glyph.layers:

        components = [c for c in layer.components if c.componentName == component_name]

        for component in components:
            component.position = (new_x, new_y)

Did you see: Python Scripting API Documentation — Python Scripting API 3.2 documentation ?

1 Like

It took time to make it work but it finally starts working. Thank you!