Looping through select list of masters

Got a basic question.
Trying to modify a mekkablue script Lines by Master but instead of looping through all the masters in the font I want it to loop of a list that I made manually.

Excerpt of orginal code

theseLayers = []
for m in Font.masters:
	for gname in names:
		layer = Font.glyphs[gname].layers[m.id]
		# print(layer)
		theseLayers.append( layer )
	
	theseLayers.append( GSControlLayer.newline() )

What I don’t quite get is what format to list masters in within theseMasters = [] so then the .id can be accessed. I tried making a comma separated listed in this format <GSFontMaster "Bold" (500.0,1000.0,0.0,0.0,100.0,0.0,0.0)> but that doesn’t work.

theseMasters = [
<GSFontMaster "Bold" (500.0,1000.0,0.0,0.0,100.0,0.0,0.0)>,
<GSFontMaster "Light" (500.0,1.0,0.0,0.0,100.0,0.0,0.0)>,
etc..
]
theseLayers = []
for m in theseMasters:
	for gname in names:
		layer = Font.glyphs[gname].layers[m.id]
		# print(layer)
		theseLayers.append( layer )
	
	theseLayers.append( GSControlLayer.newline() )
my_masters = [Font.masters[0], Font.masters[3]]

Or:

my_masters = []
for name in ["Bold", "Light"]:
    for master in Font.masters:
        if master.name == name:
            my_masters.append(master)

I should also note that you have a typo in your code (theseMasters vs. theseMaster)

1 Like

Brilliant! Thank you Sebastian!

Typo note:
my_masters.append[master]my_masters.append(master)

1 Like

Oops, jeez, it’s been a while :joy: