handle case with no labels on layer

This commit is contained in:
jan 2022-04-06 19:22:26 -07:00
parent ddf1d54304
commit c1a007d58f

View File

@ -215,6 +215,10 @@ def label_polys(
point_xys = [] point_xys = []
point_names = [] point_names = []
nets = defaultdict(list) nets = defaultdict(list)
if not labels:
return nets, merge_groups
for x, y, point_name in labels: for x, y, point_name in labels:
point_xys.append((x, y)) point_xys.append((x, y))
point_names.append(point_name) point_names.append(point_name)
@ -263,6 +267,9 @@ def label_poly(
All the `point_names` which correspond to points inside the polygon (but not in All the `point_names` which correspond to points inside the polygon (but not in
its holes). its holes).
""" """
if not point_names:
return []
poly_contour = scale_from_clipper(poly.Contour, clipper_scale_factor) poly_contour = scale_from_clipper(poly.Contour, clipper_scale_factor)
inside = poly_contains_points(poly_contour, point_xys) inside = poly_contains_points(poly_contour, point_xys)
for hole in poly.Childs: for hole in poly.Childs: