Position of nodes of corner component

Hello. I would absolutely love to find out the start and end node positions of a corner component:


I have tried most of the methods of the GSHint class, but apart from retrieving the origin, I cannot find the correct way to achieve this. Any ideas? Thanks!

You like to get the position of nodes of the inserted paths?

Yes, correct. Specifically, the positions of the nodes I circled in red (first and last node).

When the layer was drawn once, you can access the blue path:

print(Layer.hints[0].tempData["cornerHighlightPath"])

Wow, thanks! Not surprising I didn’t find that :wink:

Bonus question: What does “was drawn once” mean? What if I want to process a font that is not open?

The temp data is set when the layer is draw. It should be enough to call layer.bezierPath to set the highlight path.

Thank you. I have never worked with NSBezierPath directly and am having some difficulties finding the properties I’m looking for. I can get the first point by calling path.currentPoint(), but I can’t find the last point. I went through most of the developer documentation for NSBezierPath, but I cannot find a way to get a nice, clean pythonic list of points for the path. Could you point me somewhere?

I would not call it pythonic, but this is how you get the elements of an NSBezierPath:

bezierPath = Layer.paths[0].bezierPath
for i in range(0, bezierPath.elementCount()):
	element, points = bezierPath.elementAtIndex_associatedPoints_(i)
	# do stuff

And this is what the output looks like:

Where element is an NSBezierPathElement and points is a tuple containing the points of that element. See the elementAtIndex:associatedPoints: docs for details on the points.

The current point is not necessarily the first point, but the point where the last drawing instruction left off. Say you perform a lineToPoint: on that Bézier path, then that point will be the new current point.

Thank you very much! I had tried something similar but didn’t know what arguments to pass to elementAtIndex_associatedPoints_(), this works perfectly. Much appreciated!