diff --git a/gdsfactory/component.py b/gdsfactory/component.py index 866efdc5a38..6c40ac87afa 100644 --- a/gdsfactory/component.py +++ b/gdsfactory/component.py @@ -1597,7 +1597,7 @@ def _write_library( logging: bool = True, on_duplicate_cell: Optional[str] = "warn", with_oasis: bool = False, - max_points: int = 4e3, + max_points: Optional[int] = None, flatten_invalid_refs: bool = False, **kwargs, ) -> Path: @@ -1630,12 +1630,19 @@ def _write_library( standard_properties: Store standard OASIS properties in the file. """ - if flatten_invalid_refs: - self = flatten_invalid_refs_recursive(self) - from gdsfactory.pdk import get_grid_size + from gdsfactory.pdk import get_grid_size, get_constant precision = precision or get_grid_size() * 1e-6 + max_points = max_points or get_constant("max_points") + flatten_invalid_refs = flatten_invalid_refs or get_constant( + "flatten_invalid_refs" + ) + precision = precision or get_constant("precision") + on_duplicate_cell = on_duplicate_cell or get_constant("on_duplicate_cell") + + if flatten_invalid_refs: + self = flatten_invalid_refs_recursive(self) gdsdir = ( gdsdir or pathlib.Path(tempfile.TemporaryDirectory().name) / "gdsfactory" @@ -1708,7 +1715,7 @@ def write_gds( logging: bool = True, on_duplicate_cell: Optional[str] = "warn", flatten_invalid_refs: bool = False, - max_points: int = 4000, + max_points: Optional[int] = None, ) -> Path: """Write component to GDS and returns gdspath. @@ -1723,7 +1730,8 @@ def write_gds( "error": throw a ValueError when attempting to write a gds with duplicate cells. "overwrite": overwrite all duplicate cells with one of the duplicates, without warning. flatten_invalid_refs: flattens component references which have invalid transformations. - max_points: Maximal number of vertices per polygon. Polygons with more vertices that this are automatically fractured. + max_points: Maximal number of vertices per polygon. + Polygons with more vertices that this are automatically fractured. """ return self._write_library( @@ -1746,7 +1754,6 @@ def write_oas( logging: bool = True, on_duplicate_cell: Optional[str] = "warn", flatten_invalid_refs: bool = False, - max_points: int = 4000, **kwargs, ) -> Path: """Write component to GDS and returns gdspath. @@ -1762,6 +1769,7 @@ def write_oas( "error": throw a ValueError when attempting to write a gds with duplicate cells. "overwrite": overwrite all duplicate cells with one of the duplicates, without warning. None: do not try to resolve (at your own risk!) + flatten_invalid_refs: flattens component references which have invalid transformations. Keyword Args: compression_level: Level of compression for cells (between 0 and 9). @@ -1782,7 +1790,6 @@ def write_oas( on_duplicate_cell=on_duplicate_cell, with_oasis=True, flatten_invalid_refs=flatten_invalid_refs, - max_points=max_points, **kwargs, ) @@ -2517,6 +2524,6 @@ def hierarchy(): # c.plot_qt() # c.ploth() # c = test_extract() - c.write_oas("a.oas") - gf.show("a.oas") + gdspath = c.write_gds() + gf.show(gdspath) # c.show() diff --git a/gdsfactory/generic_tech/__init__.py b/gdsfactory/generic_tech/__init__.py index fdbed340926..d2c3866f39d 100644 --- a/gdsfactory/generic_tech/__init__.py +++ b/gdsfactory/generic_tech/__init__.py @@ -37,7 +37,7 @@ def get_generic_pdk(): from gdsfactory.components import cells from gdsfactory.config import sparameters_path from gdsfactory.cross_section import cross_sections - from gdsfactory.pdk import Pdk + from gdsfactory.pdk import Pdk, constants return Pdk( name="generic", @@ -48,6 +48,7 @@ def get_generic_pdk(): layer_views=LAYER_VIEWS, layer_transitions=LAYER_TRANSITIONS, sparameters_path=sparameters_path, + constants=constants, ) diff --git a/gdsfactory/pdk.py b/gdsfactory/pdk.py index a7deec59ead..4b70f62f27f 100644 --- a/gdsfactory/pdk.py +++ b/gdsfactory/pdk.py @@ -42,6 +42,11 @@ "fiber_spacing": 50.0, "fiber_input_to_output_spacing": 200.0, "metal_spacing": 10.0, + "max_points": 4000, + "unit": 1e-6, + "precision": 1e-9, + "flatten_invalid_refs": False, + "on_duplicate_cell": "warn", }