GSPath from GSComponent

Hi,

Is it possible to extract GSPath object from a GSComponent?

I was using Stem Thickness(github) reporter plugin, and then noticed that the plugin does not recognize the outlines of the not-decomposed smart components.

The plugin in the core uses nearestPointOnPath: pathTime: method of the GSPath, but I cannot find a way to get a representing GSPath object given a smart component.

I have tried componentLayer method of the GSComponent, but it seems to return the original layer, not the current component with the fixed smart component axes values.

I have also tried using initWithPathDict: method of the GSPath, but it couldn’t be initialized from a NSBezierPath-OAExtension’s propertyListRepresentation.

How can I get a correct GSPath outline from a smart component?

There are several ways to do that.

The easiest would be to make a copy of the layer and decompose it. That might be too slow so you need to cache the decomposed layer. But then you need to check if any of the components have been changed since you decomposed it.

Or you ask the component for its componentLayer and perform the hit detection on it. But then you need to take the transformation of the component into account, instead of transforming the layer, reverse-transform the cursor position.

Or: Take the layer.completeBezierPath and perform the hit detection off the bezier path. Then you need the reimplement the nearestPointOnPath: functionality.

Thanks for the suggestions!

I guess the first option will be too expensive to be used in a reporter plugin,
and I don’t think I can implement the nearest point algorithm myself in the NSBezierPath in a reasonable amount of time. :frowning:

Actually for the second option, as I read the docs, the method componentLayer should return the ‘interpolated’ value for the smart component, which was not the case as I tested in the macro panel. If it did return the interpolated result, there would be no problem.

Therefore I want to ask whether Is it a bug be fixed, or an intended behaviour is to return the ‘original’ smart-component-glyph layer.