Access path index to check master compatibility in a script

Is there a way to access the path index(?) to check if the masters are compatible through a script?

I do not understand what you mean. Why do you want to check for path indexes in order to see if a glyph is compatible?

You can check for layer compatibility with a layer’s compare string:

Is that what you need?

I know of compareString and i also tried mastersCompatible but they don’t take the path order into account. Even if i change the path order through fix compatibility filter i’ll still get the same string with compareString and mastersCompatible returns True regardless the path order.

How do you change the path order?

To answer you question: the layer has a property layer.indexOfPath_(path)

With correct path direction. But it sometimes fails to sort the paths.


I found two properties for the components, are they equal?



Why don’t you just try?

for i, component in enumerate(Layer.components):
    index1 = Layer.indexOfObjectInComponents_(component)
    index2 = component.index
    if index1 == index2:
        print "%i: same index: %i = %i" % (i, index1, index2)
        print "%i: DIFFERENT: %i != %i" % (i, index1, index2)

Open a glyph with many components, and run this from your Macro window.

I was wondering if they are doing something different under the hood, but i guess as long as the result is the same it doesn’t matter. Thanks :wink: