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
voidadd_this_cell(unsigned int cell_index)Adds a cell 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 libname)Set the library name
[const]unsigned intgds2_max_cellname_lengthGet the maximum length of cell names
voidgds2_max_cellname_length=(unsigned int length)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 count)Set the maximum number of vertices for polygons to write
voidgds2_multi_xy_records=(bool flag)Use multiple XY records in BOUNDARY elements for unlimited large polygons
[const]boolgds2_multi_xy_records?Get the property enabling multiple XY records for BOUNDARY elements
[const]boolgds2_no_zero_length_pathsGets a value indicating whether zero-length paths are eliminated
voidgds2_no_zero_length_paths=(bool flag)Eliminates zero-length paths if true
[const]doublegds2_user_unitsGet the user units
voidgds2_user_units=(double uu)Set the users units to write into the GDS file
[const]boolgds2_write_cell_propertiesGets a value indicating whether cell properties are written
voidgds2_write_cell_properties=(bool flag)Enables writing of cell properties if set to true
voidgds2_write_timestamps=(bool flag)Write the current time into the GDS2 timestamps if set to true
[const]boolgds2_write_timestamps?Gets a value indicating whether the current time is written into the GDS2 timestamp fields
[const]boolis_const_object?Returns a value indicating whether the reference is a const reference
voidkeep_instances=(bool flag)Enables or disables instances for dropped cells
[const]boolkeep_instances?Gets a flag indicating whether instances will be kept even if the target cell is dropped
voidno_empty_cells=(bool flag)Don't write empty cells if this flag is set
[const]boolno_empty_cells?Returns a flag indicating whether empty cells are not written.
[const]intoasis_compression_levelGet the OASIS compression level
voidoasis_compression_level=(int level)Set the OASIS compression level
voidoasis_recompress=(bool flag)Set OASIS recompression mode
[const]booloasis_recompress?Get the OASIS recompression mode
voidoasis_strict_mode=(bool flag)Sets a value indicating whether to write strict-mode OASIS files
[const]booloasis_strict_mode?Gets a value indicating whether to write strict-mode OASIS files
[const]stringoasis_substitution_charGets the substitution character
voidoasis_substitution_char=(string char)Sets the substitution character for a-strings and n-strings
voidoasis_write_cblocks=(bool flag)Sets a value indicating whether to write compressed CBLOCKS per cell
[const]booloasis_write_cblocks?Gets 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)
voidselect_this_cell(unsigned int cell_index)Selects a cell to be saved
boolset_format_from_filename(string filename)Select a format from the given file name
voidwrite_context_info=(bool flag)Enables or disables context information
[const]boolwrite_context_info?Gets a flag indicating whether context information will be stored

Deprecated methods (protected, public, static, non-static and constructors)

[const]boolgds2_multi_xy_recordsUse of this method is deprecated. Use gds2_multi_xy_records? instead
[const]boolgds2_write_timestampsUse of this method is deprecated. Use gds2_write_timestamps? instead
[const]boolno_empty_cellsUse of this method is deprecated. Use no_empty_cells? instead
[const]booloasis_recompressUse of this method is deprecated. Use oasis_recompress? instead
[const]booloasis_strict_modeUse of this method is deprecated. Use oasis_strict_mode? instead
[const]booloasis_write_cblocksUse of this method is deprecated. Use oasis_write_cblocks? instead

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.

This method also implicitly adds the children of that cell. A method that does not add the children in add_this_cell.

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.

void add_this_cell(unsigned int cell_index)

Description: Adds a cell 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. Unlike add_cell, this method does not implicitly add all children of that cell.

This method has been added in version 0.23.

[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 libname)

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 length)

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 count)

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

This method is deprecated. Use method 'gds2_multi_xy_records?' instead

void gds2_multi_xy_records=(bool flag)

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] 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.

[const] bool gds2_no_zero_length_paths

Description: Gets a value indicating whether zero-length paths are eliminated

This property has been added in version 0.23.

void gds2_no_zero_length_paths=(bool flag)

Description: Eliminates zero-length paths if true

If this property is set to true, paths with zero length will be converted to BOUNDARY objects.

This property has been added in version 0.23.

[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 uu)

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_cell_properties

Description: Gets a value indicating whether cell properties are written

This property has been added in version 0.23.

void gds2_write_cell_properties=(bool flag)

Description: Enables writing of cell properties if set to true

If this property is set to true, cell properties will be written as PROPATTR/PROPVALUE records immediately following the BGNSTR records. This is a non-standard extension and is therefore disabled by default.

This property has been added in version 0.23.

[const] bool gds2_write_timestamps

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

This method is deprecated. Use method 'gds2_write_timestamps?' instead

void gds2_write_timestamps=(bool flag)

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 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.

[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.

void keep_instances=(bool flag)

Description: Enables or disables instances for dropped cells

If this flag is set to true, instances for cells will be written, even if the cell is dropped. That may happen, if cells are selected with select_this_cell or add_this_cell or no_empty_cells is used. Even if cells called by such cells are not selected, instances will be written for that cell if "keep_instances" is true. That feature is supported by the GDS format currently and results in "ghost cells" which have instances but no cell definition.

The default value is false (instances of dropped cells are not written).

This method was introduced in version 0.23.

[const] bool keep_instances?

Description: Gets a flag indicating whether instances will be kept even if the target cell is dropped

See keep_instances= for details about this flag.

This method was introduced in version 0.23.

[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.

This method is deprecated. Use method 'no_empty_cells?' instead

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] bool no_empty_cells?

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

[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 level)

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_recompress

Description: Get the OASIS recompression mode

This method is deprecated. Use method 'oasis_recompress?' instead

void oasis_recompress=(bool flag)

Description: Set OASIS recompression mode

If this flag is true, shape arrays already existing will be resolved and compression is applied to the individual shapes again. If this flag is false (the default), shape arrays already existing will be written as such.

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

This method has been introduced in version 0.23.

[const] bool oasis_recompress?

Description: Get the OASIS recompression mode

See oasis_recompression= method for a description of the OASIS compression level. This method has been introduced in version 0.23.

[const] bool oasis_strict_mode

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

This method is deprecated. Use method 'oasis_strict_mode?' instead

void oasis_strict_mode=(bool flag)

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_strict_mode?

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

[const] string oasis_substitution_char

Description: Gets the substitution character

See oasis_substitution_char for details. This attribute has been introduced in version 0.23.

void oasis_substitution_char=(string char)

Description: Sets the substitution character for a-strings and n-strings

The substitution character is used in place of invalid characters. The value of this attribute is a string which is either empty or a single character. If the string is empty, no substitution is made at the risk of producing invalid OASIS files.

This attribute has been introduce in version 0.23.

[const] bool oasis_write_cblocks

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

This method is deprecated. Use method 'oasis_write_cblocks?' instead

void oasis_write_cblocks=(bool flag)

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] bool oasis_write_cblocks?

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

[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.

void select_this_cell(unsigned int cell_index)

Description: Selects a cell to be saved

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

This method has been added in version 0.23.

bool set_format_from_filename(string filename)

Description: Select a format from the given file name

This method will set the format according to the file's extension.

This method has been introduced in version 0.22. Beginning with version 0.23, this method always returns true, since the only consumer for the return value, Layout#write, now ignores that parameter and automatically determines the compression mode from the file name.

void write_context_info=(bool flag)

Description: Enables or disables context information

If this flag is set to false, no context information for PCell or library cell instances is written. Those cells will be converted to plain cells and KLayout will not be able to restore the identity of those cells. Use this option to enforce compatibility with other tools that don't understand the context information of KLayout.

The default value is true (context information is stored). Not all formats support context information, hence that flag has no effect for formats like CIF or DXF.

This method was introduced in version 0.23.

[const] bool write_context_info?

Description: Gets a flag indicating whether context information will be stored

See write_context_info= for details about this flag.

This method was introduced in version 0.23.