Properties

class photonforge.Properties(**kwargs)

Properties container.

Parameters:

**kwargs (int, float, str, bytes, Sequence[int, float, str, bytes]) – Named properties.

Example

>>> properties = pf.Properties(int_value=1, byte_string=b"text")
>>> properties["int_value"]
1
>>> del properties.int_value
>>> properties
Properties(**{"byte_string": b"text"})
>>> properties.byte_string
b'text'
>>> component = pf.Component()
>>> component.properties.new_value = 123
>>> component.properties
Properties(**{"new_value": 123})

Note

Sequences of length 1 are replaced by their contents. Strings are stored as ‘bytes’ using the utf-8 encoding.

Methods

add_gds_property(attribute, value)

Set a property compatible with GDSII layouts.

copy()

Create a copy of these properties.

get(key[, default])

Return the value for key if key is in properties, else default.

keys()

Return the keys for these properties.

add_gds_property(attribute, value)

Set a property compatible with GDSII layouts.

GDSII properties are stored under the “S_GDS_PROPERTY” key and are composed of a non-negative attribute number and a string value.

Parameters:
  • attribute (int) – Property attribute number.

  • value (str | bytes) – Property value. Strings are stored as bytes using the utf-8 encoding.

Returns:

This object.

Return type:

Properties

Note

GDSII files only support properties on geometrical structures, labels, and references. Properties on components (cells) are not supported and will not be included in the gds file.

copy()

Create a copy of these properties.

Returns:

New copy.

get(key, default=None)

Return the value for key if key is in properties, else default.

Parameters:
  • key (str) – Property key to retrieve.

  • default (Any) – Return value if key is not found.

Returns:

Retrieved property value or default.

Return type:

Any

keys()

Return the keys for these properties.

Returns:

Property keys.