hello @bahman @ro-hernandezz
the try/except is not really needed, I just forgot to wrap the next point index in parenthesis before performing the modulo division.
this:
nextSegment = contour[i + 1 % len(contour.segments)]
must be:
nextSegment = contour[(i + 1) % len(contour.segments)]
here’s the complete function again and an illustration of what it does, in case someone needs it in the future.
magenta = selected points / blue = implicit selected points
def getImplicitSelectedPoints(glyph):
pts = []
for contour in glyph.contours:
for i, segment in enumerate(contour.segments):
for pt in segment:
if not pt.selected:
continue
pts.append(pt)
# implicit == include BCPs in selection
if pt.type != 'offcurve':
# bcpIn
if len(segment) == 3:
bcpIn = segment[-2]
pts.append(bcpIn)
# bcpOut
nextSegment = contour[(i + 1) % len(contour.segments)]
if len(nextSegment) == 3:
bcpOut = nextSegment[0]
pts.append(bcpOut)
return pts
# visualize it with the DrawBot extension
g = CurrentGlyph()
size(700, 700)
translate(30, 100)
fill(None)
strokeWidth(4)
stroke(0, 1, 1)
drawGlyph(g)
fill(0, 0, 1)
stroke(None)
r = 10
for pt in getImplicitSelectedPoints(g):
oval(pt.x - r, pt.y - r, r * 2, r * 2)
fill(None)
stroke(1, 0, 1)
r += 5
for pt in g.selectedPoints:
oval(pt.x - r, pt.y - r, r * 2, r * 2)