How do I access the basic methods from a plugin?

In the GlyphsApi docs there’s a list of “methods”. In the macro window where I can play around with trial and error I can use the intersectPaths-method.

https://docu.glyphsapp.com/#methods

But when I try to use it inside my plugin, it looks like the intersectPaths-method isn’t known from within the classes I’ve declared to try and package it in different modules.

I’ve tried looking through the Font and Glyphs object, but I can’t see any “intersectPaths”-method, so I’m guessing it’s declared somewhere else. Is there some preferred way of using these “global” functions from within a Python plugin?

I second this.

It is not clear from the linked documentation, on which object these methods are to be called.

I know for example that removeOverlap() is called on the layer. But that is not stated in the documentation.
But then, subtractPaths() and intersectPaths() are mentioned right behind removeOverlap in the documentation, but those are not called on the layer.

Could that please be clarified in the documentation?

Also: How to actually do the boolean operation nowadays? The method described here does not work:

AttributeError: 'GSPathOperator' object has no attribute 'intersectPaths_from_error_'

You can check the header of the GSPathOperator: Glyphs 3.app/Contents/Frameworks/GlyphsCore.framework/Versions/A/Headers/GSPathOperator.h

That should give you the latest API.

Thank you. I’ll have a look.

The issue with the documentation persists, though. The mentioned methods are located in a seemingly random location and it is not clear to the reader where they belong to. That needs fixing :slight_smile:

Managed to make it work. These are class methods (now) so the GSPathOperator needs not to be instantiated.

Follow up question: Can one use one of the operator methods to use an open path to cut another path? Could not get make it work with any of the subtract or intersect methods.

You mean something like the knife tool?

Yes, but with a curve.

There are two different methods. The standalone function (your link pointed to that one), and the layer method.

So how is the standalone method to be called? I ask from the perspective of a user of the documentation. It is not really clear there. That was my point to ask if that can be clarified in the documentation.

I added a code sample:

paths = [path1, path2, path3]
mergePaths = removeOverlap(paths)
1 Like

Thank you a lot!

I updated the docu.