"Variable font setting" via Script

Hi there
I’m trying to create Variable font setting via scripting.
I found this method Custom Parameter "Variable font file name" has no effect in an old post. But for some reason it doesn’t recognize GSInstance(type=INSTANCETYPEVARIABLE).
So what is wrong with this?

new_instance = GSInstance(type=INSTANCETYPEVARIABLE)
new_instance.name = "Something"
new_instance.customParameters['Filter'] = ["Transformations; Width: +20000; include:space"]
font.instances.append(new_instance)

Thanks,
Andreas

It should be this:

new_instance = GSInstance()
new_instance.type = INSTANCETYPEVARIABLE
new_instance.name = "Something"
new_instance.customParameters['Filter'] = ["Transformations; Width: +20000; include:space"]
font.instances.append(new_instance)

But for whatever reason, type does not have a setter (yet). Until that is fixed, try replacing the first two lines with this PyObjC monster:

new_instance = GSInstance.alloc().initWithType_(INSTANCETYPEVARIABLE)

Great! Thank you so much!

I fixed the initializer. It is supposed to be:

new_instance = GSInstance(INSTANCETYPEVARIABLE)
new_instance.name = "Something"
…

Will be in the next update.

What is the instance type supposed to be? Did you mean to write something after i.type = ?

No. I’ll fix the code.