Automate script for layer settings of smart component

Hi there, is there any automate script for layer settings of smart component.

I work with smart components a lot for the recent Chinese type project. In most of the time I only need layers of Width (normally the first and second layers) and Height (the third layer). If there is an automate script for that will save a lot of time :wink:

Hello, can you describe in a bit more detail what you mean, exactly? I don’t quite understand. Do you want to manage settings in smart components themselves? Or adjust the settings of smart components in composites? Why not use the interfacesprovided? Do you want to batch-manage the settings for multiple selected layers?

I use smart glyph settings interface which takes a few steps: open the window, type in Width and Height, choose layers and their settings, close the window… I am building hundreds of smart components and doing this repeatedly makes me annoying.

Can you explain exactly what do you want the script to do?

I want the script to help me: fill in Width and Height in Properties tab and pick the first two layers for different Width and the third layer same Width with the first layer but different Height.

You’ll have to be a bit more precise than that, I’m afraid. Otherwise I can’t write something that will work for you. Can you maybe post a screenshot of the setup you want to achieve?

Do you want the script to set a certain value, or do you need a UI that allows you to control things? Do you want it to apply to muliple glyphs at once?


In Glyphs2 it is allowed to set properties to a certain value but not in Glyphs3. A script that runs in background will be helpful to me. If it can apply to multiple glyphs in one time, that will be a bonus.

Thank you. That is very helpful.

So, let me get this straight:

The project has exactly one master.
You have a smart component (or multiple?) with exactly two extra layers.
The smart component needs two axes: Width and Height. Each (?) with a range of 0–100.
The master layer is set to 1 on both axes (left: 0, right: 1).
The first extra layer is set to Width:0, Height:1
The second extra layer is set to Width:0, Height:0

Is this all correct? I could put this into a script for you, but I don’t currently have the time to make it very flexible :slight_smile:

The project has only ONE master.

Each component has basically three layers.
The master layer is set to 0(W), 1(H)
The first extra layer is set to 1(W), 1(H)
The second extra layer is set to 1(W), 0(H)

Sometime I need the smart component for either Width or Height variation. But I can simply duplicate the layer for future potential. If I need more axes, I can do add manually.

Thanks for you help! :heart:

Hmm, so not like on your screenshot?

I used your last comment, which has a different setup described as in the screenshot:

for layer in Font.selectedLayers:
	try:
		layer.parent.smartComponentAxes["Width"]
	except:
		widthAxis = GSSmartComponentAxis()
		widthAxis.topValue = 100
		widthAxis.bottomValue = 0
		widthAxis.name = "Width"
		layer.parent.smartComponentAxes.append(widthAxis)
		smartWidthAxis = layer.parent.smartComponentAxes["Width"]

	try:
		layer.parent.smartComponentAxes["Height"]
	except:
		heightAxis = GSSmartComponentAxis()
		heightAxis.topValue = 100
		heightAxis.bottomValue = 0
		heightAxis.name = "Height"
		layer.parent.smartComponentAxes.append(heightAxis)
		smartHeightAxis = layer.parent.smartComponentAxes["Height"]

		
	layer.parent.layers[0].smartComponentPoleMapping[smartWidthAxis.id] = 1
	layer.parent.layers[0].smartComponentPoleMapping[smartHeightAxis.id] = 2
	layer.parent.layers[1].smartComponentPoleMapping[smartWidthAxis.id] = 2
	layer.parent.layers[1].smartComponentPoleMapping[smartHeightAxis.id] = 2
	layer.parent.layers[2].smartComponentPoleMapping[smartWidthAxis.id] = 2
	layer.parent.layers[2].smartComponentPoleMapping[smartHeightAxis.id] = 1

Select the smart components you want to edit (backup your file beforehand!) and run the script.

1 Like