# SOLVEDFinding bPoint for RPoint and the other way around

• Is there any less “loopy” way to do these?
(if there is none, then it sucks. it's slowing down my super-duper-fancy unpublished scripts)

``````def getPointFromBPoint(bPoint):
"""Returns RPoint that is an equivalent to given RBPoint"""
glyph = bPoint.getParent().getParent() # Normally I use CurrenGlyph()
onCurvePointsContours = [[p for p in c.points if p.type != "offcurve"] for c in glyph ]
for i_c,c in enumerate(onCurvePointsContours):
if bPoint.getParent().index == i_c:
for i_p,p in enumerate(c):
if bPoint.index == i_p:
return p

def getBPointFromPoint(point):
"""Returns RBPoint that is an equivalent to given RPoint"""
glyph = point.getParent().getParent() # Normally I use CurrenGlyph()
onCurvePointsContours = [[p for p in c.points if p.type != "offcurve"] for c in glyph ]
for i_c,c in enumerate(onCurvePointsContours):
if point.getParent().index == i_c:
for i_p,p in enumerate(c):
if point == p:
return glyph[i_c].bPoints[i_p]
``````

Cheers

• ``````from fontParts.fontshell import RBPoint

g = CurrentGlyph()
c = g
p = c.segments.onCurve

# point to bPoint
bp = RBPoint()
bp._setPoint(p)
bp.contour = c

print(bp)

# bPoint to point
print(bp._point == p)
``````

• hello @RafaŁ-Buchner,

you can get a point from a bPoint directly. not sure about the other way around.

``````def getPointFromBPoint(bPoint):
return bPoint._point

def getBPointFromPoint(point):
onCurvePointsContours = [[p for p in c.points if p.type != "offcurve"] for c in point.glyph]
for ci, c in enumerate(onCurvePointsContours):
if point.contour.index == ci:
for pi, p in enumerate(c):
if point == p:
return glyph[ci].bPoints[pi]

# testing
glyph = CurrentGlyph()
bPoint = glyph.bPoints
point = getPointFromBPoint(bPoint)
bPoint2 = getBPointFromPoint(point)
print(bPoint)
print(point)
print(bPoint2)
print(bPoint == bPoint2)
``````

note that `getParent()` is deprecated – you can get parent objects as attributes now: `point.contour`, `point.glyph` etc.

good luck!

• ``````from fontParts.fontshell import RBPoint

g = CurrentGlyph()
c = g
p = c.segments.onCurve

# point to bPoint
bp = RBPoint()
bp._setPoint(p)
bp.contour = c

print(bp)

# bPoint to point
print(bp._point == p)
``````

• Thanks!!!!