smartComponentValues problems

I’m trying to write a plug-in now, and there are 2 problems about smartComponentValues occurred in my test.

The first is, Glyphs always crash when click the OK button in dialog when I add a smart component and set the smartComponentValues by scripting.

# Issue 1

layer = Glyphs.font.selectedLayers[0]
comp = GSComponent('_part.test')
layer.components.append(comp)
comp.smartComponentValues['Width'] = 50
comp.smartComponentValues['Height'] = 30

# Glyphs App crash here when open Smart Component Value dialog and click OK
# App will not crash if adjust size by mouse first

The second is, when I copy the layer, and run the code below in the new layer, component’s outward do not change (but it changed in script level).

# Issue 2
# Copy layer, and run the code in the new layer
comp = Glyphs.font.selectedLayers[0].components[0]
comp.smartComponentValues['Width'] = 80

print comp.smartComponentValues
# <GSNotifyingDictionary: 0x60000062c260> {
#    Height = "46.79218682479114";
#    Width = 80;   <= in script base, the value changed exactly. 
# }
# However, component in the UI is still shown as the original width.
# component do not change until set the value via dialog or resize by mouse manually

Glyphs version is 2.6.4 (1286).

Can you send me the .glyphs file you used for the test.

And can you test the latest cutting edge version?

i’ve tried in 2.6.5, and the 2 issues still occurred.

SmartCompScriptingIssue.glyphs (9.5 KB)

I tried to record the issues in a video here.

https://drive.google.com/file/d/1TtlU3aQVWoUoN2CTHkS-CKGdK-gVLrC_/view?usp=sharing

I fixed it. For now, use this code to make the component:

layer = Glyphs.font.selectedLayers[0]
comp = GSComponent('_part.test')
layer.components.append(comp)
comp.setPieceValue_forKey_(50, 'Width')
comp.setPieceValue_forKey_(30, 'Height')
1 Like

Thank you very much!
It works in the both issues.