diff --git a/masque/file/gdsii.py b/masque/file/gdsii.py index 79a8f67..e218545 100644 --- a/masque/file/gdsii.py +++ b/masque/file/gdsii.py @@ -13,7 +13,7 @@ import numpy from .utils import mangle_name, make_dose_table from .. import Pattern, SubPattern, PatternError from ..shapes import Polygon -from ..utils import rotation_matrix_2d, get_bit, vector2 +from ..utils import rotation_matrix_2d, get_bit, set_bit, vector2, is_scalar __author__ = 'Jan Petykiewicz' @@ -76,15 +76,15 @@ def write(patterns: Pattern or List[Pattern], for polygon in shape.to_polygons(): xy_open = numpy.round(polygon.vertices + polygon.offset).astype(int) xy_closed = numpy.vstack((xy_open, xy_open[0, :])) - if hasattr(polygon.layer, '__len__'): + if is_scalar(polygon.layer): + layer = polygon.layer + data_type = 0 + else: layer = polygon.layer[0] if len(polygon.layer) > 1: data_type = polygon.layer[1] else: data_type = 0 - else: - layer = polygon.layer - data_type = 0 structure.append(gdsii.elements.Boundary(layer=layer, data_type=data_type, xy=xy_closed)) @@ -184,10 +184,10 @@ def write_dose2dtype(patterns: Pattern or List[Pattern], data_type = dose_vals_list.index(polygon.dose * pat_dose) xy_open = numpy.round(polygon.vertices + polygon.offset).astype(int) xy_closed = numpy.vstack((xy_open, xy_open[0, :])) - if hasattr(polygon.layer, '__len__'): - layer = polygon.layer[0] - else: + if is_scalar(polygon.layer): layer = polygon.layer + else: + layer = polygon.layer[0] structure.append(gdsii.elements.Boundary(layer=layer, data_type=data_type, xy=xy_closed))