KLayout Manual: Main Index » Class Index » API reference - Class SaveLayoutOptions

API reference - Class SaveLayoutOptions

Notation used in Ruby API documentation

Description: Options for saving layouts

This class describes the various options for saving a layout to a stream file (GDS2, OASIS and others). There are: layers to be saved, cell or cells to be saved, scale factor, format, database unit and format specific options.

Usually the default constructor provides a suitable object. Please note, that the format written is "GDS2" by default. Either explicitly set a format using format= or derive the format from the file name using set_format_from_filename.

The layers are specified by either selecting all layers or by defining layer by layer using the add_layer method. select_all_layers will explicitly select all layers for saving, deselect_all_layers will explicitly clear the list of layers.

Cells are selected in a similar fashion: by default, all cells are selected. Using add_cell, specific cells can be selected for saving. All these cells plus their hierarchy will then be written to the stream file.

Public constructors

new SaveLayoutOptionsnewDefault constructor

Public methods

voidadd_cell(unsigned int cell_index)Add a cell (plus hierarchy) to be saved
voidadd_layer(unsigned int layer_index,
const LayerInfo properties)
Add a layer to be saved
[const]voidassign(const SaveLayoutOptions other)Assign the contents of another object to self
voidclear_cellsClears all cells to be saved
voidcreateEnsures the C++ object is created
[const]doubledbuGet the explicit database unit if one is set
voiddbu=(double dbu)Set the database unit to be used in the stream file
voiddeselect_all_layersUnselect all layers: no layer will be saved
voiddestroyExplicitly destroy the object
[const]booldestroyed?Returns a value indicating whether the object was already destroyed
[const]SaveLayoutOptionsdupCreates a copy of self
[const]intdxf_polygon_modeSpecifies how to write polygons.
voiddxf_polygon_mode=(int mode)Specifies how to write polygons.
[const]stringformatGets the format name
voidformat=(string format)Select a format
[const]stringgds2_libnameGet the library name
voidgds2_libname=(string arg1)Set the library name
[const]unsigned intgds2_max_cellname_lengthGet the maximum length of cell names
voidgds2_max_cellname_length=(unsigned int arg1)Maximum length of cell names
[const]unsigned intgds2_max_vertex_countGet the maximum number of vertices for polygons to write
voidgds2_max_vertex_count=(unsigned int arg1)Set the maximum number of vertices for polygons to write
[const]boolgds2_multi_xy_recordsGet the property enabling multiple XY records for BOUNDARY elements
voidgds2_multi_xy_records=(bool arg1)Use multiple XY records in BOUNDARY elements for unlimited large polygons
[const]doublegds2_user_unitsGet the user units
voidgds2_user_units=(double arg1)Set the users units to write into the GDS file
[const]boolgds2_write_timestampsGets a value indicating whether the current time is written into the GDS2 timestamp fields
voidgds2_write_timestamps=(bool arg1)Write the current time into the GDS2 timestamps if set to true
[const]boolis_const_object?Returns a value indicating whether the reference is a const reference
[const]boolno_empty_cellsReturns a flag indicating whether empty cells are not written.
voidno_empty_cells=(bool flag)Don't write empty cells if this flag is set
[const]intoasis_compression_levelGet the OASIS compression level
voidoasis_compression_level=(int arg1)Set the OASIS compression level
[const]booloasis_strict_modeGets a value indicating whether to write strict-mode OASIS files
voidoasis_strict_mode=(bool arg1)Sets a value indicating whether to write strict-mode OASIS files
[const]booloasis_write_cblocksGets a value indicating whether to write compressed CBLOCKS per cell
voidoasis_write_cblocks=(bool arg1)Sets a value indicating whether to write compressed CBLOCKS per cell
[const]doublescale_factorGets the scaling factor currently set
voidscale_factor=(double scale_factor)Set the scaling factor for the saving
voidselect_all_cellsSelect all cells to save
voidselect_all_layersSelect all layers to be saved
voidselect_cell(unsigned int cell_index)Selects a cell to be saved (plus hierarchy below)
boolset_format_from_filename(string filename)Select a format from the given file name

Detailed description

void add_cell(unsigned int cell_index)

Description: Add a cell (plus hierarchy) to be saved

The index of the cell must be a valid index in the context of the layout that will be saved. This method clears the 'select all cells' flag.

void add_layer(unsigned int layer_index,const LayerInfo properties)

Description: Add a layer to be saved

Adds the layer with the given index to the layer list that will be written. If all layers have been selected previously, all layers will be unselected first and only the new layer remains.

The 'properties' argument can be used to assign different layer properties than the ones present in the layout. Pass a default LayerInfo object to this argument to use the properties from the layout object. Construct a valid LayerInfo object with explicit layer, datatype and possibly a name to override the properties stored in the layout.

[const] void assign(const SaveLayoutOptions other)

Description: Assign the contents of another object to self

This method assigns the contents of another object to self. This is a deep copy that does not only copy the reference but the actual content.

void clear_cells

Description: Clears all cells to be saved

This method can be used to ensure that no cell is selected before add_cell is called to specify a cell. This method clears the 'select all cells' flag.

This method has been added in version 0.22.

void create

Description: Ensures the C++ object is created

Use this method to ensure the C++ object is created, for example to ensure that resources are allocated. Usually C++ objects are created on demand and not necessarily when the script object is created.

[const] double dbu

Description: Get the explicit database unit if one is set

See dbu= for a description of that attribute.

void dbu=(double dbu)

Description: Set the database unit to be used in the stream file

By default, the database unit of the layout is used. This method allows to explicitly use a different database unit. A scale factor is introduced automatically which scales all layout objects accordingly so their physical dimensions remain the same. When scaling to a larger database unit or one that is not an integer fraction of the original one, rounding errors may occur and the layout may become slightly distorted.

void deselect_all_layers

Description: Unselect all layers: no layer will be saved

This method will clear all layers selected with add_layer so far and clear the 'select all layers' flag. Using this method is the only way to save a layout without any layers.

void destroy

Description: Explicitly destroy the object

Explicitly destroy the object on C++ side if it was owned by the Ruby interpreter. Subsequent access to this object will throw an exception. If the object is not owned by Ruby, this method will do nothing.

[const] bool destroyed?

Description: Returns a value indicating whether the object was already destroyed

This method returns true, if the object was destroyed, either explicitly or by the C++ side. The latter may happen, if the object is owned by a C++ object which got destroyed itself.

[const] SaveLayoutOptions dup

Description: Creates a copy of self

[const] int dxf_polygon_mode

Description: Specifies how to write polygons.

See dxf_polygon_mode= for a description of this property.

This property has been added in version 0.21.3.

void dxf_polygon_mode=(int mode)

Description: Specifies how to write polygons.

The mode is 0 (write POLYLINE entities), 1 (write LWPOLYLINE entities), 2 (decompose into SOLID entities) or or 3 (write HATCH entities).

This property has been added in version 0.21.3.

[const] string format

Description: Gets the format name

See format= for a description of that method.

void format=(string format)

Description: Select a format

The format string can be either "GDS2", "OASIS", "CIF" or "DXF". Other formats may be available if a suitable plugin is installed.

[const] string gds2_libname

Description: Get the library name

See gds2_libname= method for a description of the library name. This property has been added in version 0.18.

void gds2_libname=(string arg1)

Description: Set the library name

The library name is the string written into the LIBNAME records of the GDS file. The library name should not be an empty string and is subject to certain limitations in the character choice.

This property has been added in version 0.18.

[const] unsigned int gds2_max_cellname_length

Description: Get the maximum length of cell names

See gds2_max_cellname_length= method for a description of the maximum cell name length. This property has been added in version 0.18.

void gds2_max_cellname_length=(unsigned int arg1)

Description: Maximum length of cell names

This property describes the maximum number of characters for cell names. Longer cell names will be shortened.

This property has been added in version 0.18.

[const] unsigned int gds2_max_vertex_count

Description: Get the maximum number of vertices for polygons to write

See gds2_max_vertex_count= method for a description of the maximum vertex count. This property has been added in version 0.18.

void gds2_max_vertex_count=(unsigned int arg1)

Description: Set the maximum number of vertices for polygons to write

This property describes the maximum number of point for polygons in GDS2 files. Polygons with more points will be split. The minimum value for this property is 4. The maximum allowed value is about 4000 or 8000, depending on the GDS2 interpretation. If gds2_multi_xy_records is true, this property is not used. Instead, the number of points is unlimited.

This property has been added in version 0.18.

[const] bool gds2_multi_xy_records

Description: Get the property enabling multiple XY records for BOUNDARY elements

See gds2_multi_xy_records= method for a description of this property. This property has been added in version 0.18.

void gds2_multi_xy_records=(bool arg1)

Description: Use multiple XY records in BOUNDARY elements for unlimited large polygons

Setting this property to true allows to produce unlimited polygons at the cost of incompatible formats. Setting it to true disables the gds2_max_vertex_count setting.

This property has been added in version 0.18.

[const] double gds2_user_units

Description: Get the user units

See gds2_user_units= method for a description of the user units. This property has been added in version 0.18.

void gds2_user_units=(double arg1)

Description: Set the users units to write into the GDS file

The user units of a GDS file are rarely used and usually are set to 1 (micron). The intention of the user units is to specify the display units. KLayout ignores the user unit and uses microns as the display unit. The user unit must be larger than zero.

This property has been added in version 0.18.

[const] bool gds2_write_timestamps

Description: Gets a value indicating whether the current time is written into the GDS2 timestamp fields

This property has been added in version 0.21.16.

void gds2_write_timestamps=(bool arg1)

Description: Write the current time into the GDS2 timestamps if set to true

If this property is set to false, the time fields will all be zero. This somewhat simplifies compare and diff applications.

This property has been added in version 0.21.16.

[const] bool is_const_object?

Description: Returns a value indicating whether the reference is a const reference

This method returns true, if self is a const reference. In that case, only const methods may be called on self.

[static] new SaveLayoutOptions new

Description: Default constructor

This will initialize the scale factor to 1.0, the database unit is set to "same as original" and all layers are selected as well as all cells. The default format is GDS2.

[const] bool no_empty_cells

Description: Returns a flag indicating whether empty cells are not written.

void no_empty_cells=(bool flag)

Description: Don't write empty cells if this flag is set

By default, all cells are written (no_empty_cells is false). This applies to empty cells which do not contain shapes for the specified layers as well as cells which are empty because they reference empty cells only.

[const] int oasis_compression_level

Description: Get the OASIS compression level

See oasis_compression_level= method for a description of the OASIS compression level.

void oasis_compression_level=(int arg1)

Description: Set the OASIS compression level

The OASIS compression level is an integer number between 0 and 10. 0 basically is no compression, 1 produces shape arrays in a simple fashion. 2 and higher compression levels will use a more elaborate algorithm to find shape arrays which uses 2nd and futher neighbor distances. The higher the level, the higher the memory requirements and run times. Setting this property clears all format specific options for other formats such as GDS.

[const] bool oasis_strict_mode

Description: Gets a value indicating whether to write strict-mode OASIS files

void oasis_strict_mode=(bool arg1)

Description: Sets a value indicating whether to write strict-mode OASIS files

Setting this property clears all format specific options for other formats such as GDS.

[const] bool oasis_write_cblocks

Description: Gets a value indicating whether to write compressed CBLOCKS per cell

void oasis_write_cblocks=(bool arg1)

Description: Sets a value indicating whether to write compressed CBLOCKS per cell

Setting this property clears all format specific options for other formats such as GDS.

[const] double scale_factor

Description: Gets the scaling factor currently set

void scale_factor=(double scale_factor)

Description: Set the scaling factor for the saving

Using a scaling factor will scale all objects accordingly. This scale factor adds to a potential scaling implied by using an explicit database unit.

Be aware that rounding effects may occur if fractional scaling factors are used.

By default, no scaling is applied.

void select_all_cells

Description: Select all cells to save

This method will clear all cells specified with add_cells so far and set the 'select all cells' flag. This is the default.

void select_all_layers

Description: Select all layers to be saved

This method will clear all layers selected with add_layer so far and set the 'select all layers' flag. This is the default.

void select_cell(unsigned int cell_index)

Description: Selects a cell to be saved (plus hierarchy below)

This method is basically a convenience method that combines clear_cells and add_cell. This method clears the 'select all cells' flag.

This method has been added in version 0.22.

bool set_format_from_filename(string filename)

Description: Select a format from the given file name

Returns:true, if the file name indicates gzip compression

This method will set the format according to the file's extension. It returns a value that can be used for the gzip option in Layout::write, if the file name indicates a compressed format. For example, "file.gds" will set the format to "GDS2" and return false. "file.oas.gz" will set the format to "OASIS" and return true.

This method has been introduced in version 0.22.