Methods for plugins

I’m trying to create a script that use the Roughneizer plugin, I was looking to other script to learn how to call it, Could you give me some information about the methods needed for Roughenizer?

I’m very newbie with Python, with “methods” I refer the words between underscore, I don’t know if it’s the correct term.

here an example I was seeing.

offsetCurveFilter.offsetLayer_offsetX_offsetY_makeStroke_autoStroke_position_error_shadow_( Layer, noodleRadius, noodleRadius, True, False, 0.5, None,None)

Best regards.

PS: Sorry for my bad english.

That would be:

roughenFilter = NSClassFromString("GlyphsFilterRoughenizer").alloc().init()
roughenFilter.roughenLayer_segmentLength_offsetX_offsetY_angle_shadowLayer_error_(Layer, SegmentLength, OffsetX, OffsetY, Angle, None, None)

Or use the more generic method:

Arguments = [SegmentLength, OffsetX, OffsetY, Angle]
roughenFilter.processLayer_withArguments_(Layer, Arguments)

The later is available for all Filter that support the Custom Property ‘Filter’


Thanks Georg!

Looks like offsetLayer_offsetX_offsetY_makeStroke_position_error_shadow_ is not working anymore?

AttributeError: No attribute offsetLayer_offsetX_offsetY_makeStroke_position_error_shadow_

Any tips on how to bring the used functionality back to live? Many many thanks in advance

I probably added an argument. dir() should give you some hints.

I printed the entire Help on class GlyphsFilterOffsetCurve, but even with the search I don’t find any matches for “offsetL” … if I just search for “offset”, I only see 4 methods (setOffsetXField_, setOffsetX_, setOffsetYField_, setOffsetY_) and the 2 matching XField attributes for those. Same in the Method Reporter … When I search for Layer, I just see 3 runFilterWithLayer… methods. But they look different.

That is interesting: dir() only shows the instance methods, not the class methods. It seems you specifically have to ask for the class methods:

GlyphsFilterOffsetCurve = NSClassFromString("GlyphsFilterOffsetCurve")
print dir(GlyphsFilterOffsetCurve.__class__)
1 Like

Thank you! Found the stuff there. Looks fun!

Is there a way to see what data type can be passed into each parameter? From this thread I found the method: offsetLayer_offsetX_offsetY_makeStroke_autoStroke_position_metrics_error_shadow_capStyle_keepCompatibleOutlines_

But I’m not sure what to pass into the method parameters.

What I’m trying to do is run the offsetFilter without the corners getting chopped, as in the attached image.


Does this help?

offsetLayer_offsetX_offsetY_makeStroke_autoStroke_position_metrics_error_shadow_capStyle_keepCompatibleOutlines_(Layer, OffsetX, OffsetY, True, False, 0.5, metrics, None, None, 0, True)
1 Like

How to give the metrics parameter

metrics = layer.metrics

Thanks,In glyphs2 ,there is an error:
Traceback (most recent call last):
File “”, line 5, in
AttributeError: ‘NSKVONotifying_GSLayer’ object has no attribute ‘metrics’

In Glyphs 2, it is

metrics = layer.glyphMetrics()

How can I run a filter from a remote script?

I tried the following but None is returned

GlyphsFilterOffsetCurve = NSClassFromString("GlyphsFilterOffsetCurve")

This doesn’t work over the app proxy.

But I added a method that gets a class through the proxy. Please try this:

GlyphsFilterOffsetCurve = Glyphs.objectWithClassName_("GlyphsFilterOffsetCurve")

Thanks, this works!