gdsfactory.typings.Component#
- class gdsfactory.typings.Component(name: str = 'Unnamed', with_uuid: bool = False, max_name_length: int | None = None)[source]#
A Component is an empty canvas where you add polygons, references and ports (to connect to other components).
stores settings that you use to build the component
stores info that you want to use
can return ports by type (optical, electrical …)
can return netlist for circuit simulation
can write to GDS, OASIS
can show in KLayout, matplotlib, 3D
can return copy, mirror, flattened (no references)
- Parameters:
name – component_name. Use @cell decorator for auto-naming.
with_uuid – adds unique identifier.
- Properties:
- info: dictionary that includes
derived properties
external metadata (test_protocol, docs, …)
simulation_settings
function_name
name: for the component
- settings:
full: full settings passed to the function to create component. changed: changed settings. default: default component settings. child: dict info from the children, if any.
- __init__(name: str = 'Unnamed', with_uuid: bool = False, max_name_length: int | None = None) None [source]#
Initialize the Component object.
- Parameters:
name – component_name. Use @cell decorator for auto-naming.
with_uuid – adds unique identifier.
max_name_length – maximum number of characters for component name.
Methods
__init__
([name, with_uuid, max_name_length])Initialize the Component object.
absorb
(reference)Absorbs polygons from ComponentReference into Component.
add
(element)Add a new element or list of elements to this Component.
add_array
(component[, columns, rows, ...])Creates a ComponentReference reference to a Component.
add_label
([text, position, magnification, ...])Adds Label to the Component.
add_padding
(**kwargs)Returns same component with padding.
add_pins_triangle
([port_marker_layer, ...])Returns component with triangular pins.
add_polygon
(points[, layer, snap_to_grid])Adds a Polygon to the Component.
add_port
([name, center, width, orientation, ...])Add port to component.
add_ports
(ports[, prefix, suffix])Add a list or dict of ports.
add_ref
(component[, alias])Add ComponentReference to the current Component.
add_ref_container
(component)Add reference, ports and copy_child_info.
add_route_info
(cross_section, length[, ...])Adds route information to a component.
align
([elements, alignment])Align elements in the Component.
area
([layer])Returns the area of the component.
assert_ports_manhattan
([error_type])Asserts that all ports are on manhattan angles (0, 90, 180, 270).
assert_ports_on_grid
([grid_factor, error_type])Asserts that all ports are on grid.
auto_rename_ports
(**kwargs)Rename ports by orientation NSEW (north, south, east, west).
auto_rename_ports_counter_clockwise
(**kwargs)auto_rename_ports_layer_orientation
(**kwargs)auto_rename_ports_orientation
(**kwargs)Rename ports by orientation NSEW (north, south, east, west).
copy
([name])copy_child_info
(component)Copy and settings info from child component into parent.
distribute
([elements, direction, spacing, ...])Distributes the specified elements in the Component.
extract
(layers[, include_labels, recursive])Extract polygons from a Component and returns a new Component.
flatten
([single_layer])Returns a flattened copy of the component.
flatten_invalid_refs
(*args, **kwargs)Flatten all invalid references.
flatten_offgrid_references
([grid_size, ...])Returns new component with flattened references so that they snap to grid.
flatten_reference
(ref)From existing cell replaces reference with a flatten reference which has the transformations already applied.
get_component_spec
()get_dependencies
([recursive])Return a list of Components referenced by this Component.
get_info
()Gathers the .info dictionaries from every sub-Component and returns them in a list.
get_labels
([apply_repetitions, depth, layer])Return labels.
get_layer_names
()Return layer names used in the design.
get_layers
()Return a set of (layer, datatype).
get_netlist
(**kwargs)From Component returns instances, connections and placements dict.
get_netlist_flat
(**kwargs)Returns a netlist where all subinstances are exposed and independently named.
get_netlist_recursive
(**kwargs)Returns recursive netlist for a component and subcomponents.
get_netlist_yaml
(**kwargs)get_polygon_bbox
([default, top, bottom, ...])Returns shapely Polygon with bounding box.
get_polygon_enclosure
()Returns Polygon enclosure.
get_polygons
([by_spec, depth, ...])Return a list of polygons in this cell.
get_ports
([depth])Returns copies of all the ports of the Component, rotated and translated so that they're in their top-level position.
get_ports_dict
(**kwargs)Returns a dict of ports.
get_ports_list
(**kwargs)Returns list of ports.
get_ports_pandas
()get_ports_polars
()get_ports_xsize
(**kwargs)Returns xdistance from east to west ports.
get_ports_ysize
(**kwargs)Returns ydistance from east to west ports.
get_setting
(setting)hash_geometry
([precision])Returns an SHA1 hash of the geometry in the Component.
is_unlocked
()Raises warning if Component is locked.
lock
()Makes sure components can't add new elements or move existing ones.
mirror
([p1, p2])Returns new Component with a mirrored reference.
move
(*args, **kwargs)Make a reference instead
movex
([origin, destination])Moves an object by a specified x-distance.
movey
([origin, destination])Moves an object by a specified y-distance.
offset
([distance, use_union, precision, ...])Returns new Component with polygons eroded or dilated by an offset.
plot
([plotter])Returns component plot using klayout, matplotlib, or kweb.
plot_klayout
([show_ports, ...])Returns klayout image.
plot_kweb
()Shows current gds in kweb.
plot_matplotlib
(**kwargs)Plot component using matplotlib.
plot_netlist
([with_labels, font_weight])Plots a netlist graph with networkx.
plot_netlist_flat
([with_labels, font_weight])Plots a netlist graph with networkx.
port_by_orientation_ccw
(key, **kwargs)Returns port by indexing them clockwise.
port_by_orientation_cw
(key, **kwargs)Returns port by indexing them clockwise.
pprint
()Prints component info.
pprint_ports
([sort_by_name])Prints ports in a rich table.
ref
([position, port_id, rotation, h_mirror, ...])Returns Component reference.
ref_center
([position])Returns a reference of the component centered at (x=0, y=0).
remap_layers
(layermap[, new_copy])Returns a copy of the component with remapped layers, unless new_copy is set to False, in which case it modifies the current Component in place.
remove
(items)Removes items from a Component, which can include Ports, PolygonSets CellReferences, ComponentReferences and Labels.
remove_labels
()Remove labels.
remove_layers
(layers[, include_labels, ...])Remove a list of layers and returns the same Component.
rename
(name[, cache, max_name_length])rotate
([angle])Returns new component with a rotated reference to the original.
show
([show_ports, show_subports, ...])Show component in KLayout.
simplify
([tolerance])Removes points from the polygon but does not change the polygon shape by more than tolerance from the original.
snap_ports_to_grid
([grid_factor])to_3d
([layer_views, layer_stack, exclude_layers])Return Component 3D trimesh Scene.
to_dict
([ignore_components_prefix, ...])Returns Dict representation of a component.
to_dict_yaml
(**kwargs)Write Dict representation of a component in YAML format.
to_gmsh
(*args, **kwargs)Deprecated.
to_kfactory
()Converts the component to KLayout Component.
to_np
([nm_per_pixel, layers, values, pad_width])Returns a pixelated numpy array from Component polygons.
to_yaml
(**kwargs)unlock
()Only do this if you know what you are doing.
validate
(v, _info)Pydantic assumes component is valid if the following are true.
write_gds
([gdspath, gdsdir])Write component to GDS and returns gdspath.
write_gerber
(dirpath, ...)- param dirpath:
directory to write gerber files to.
write_netlist
(filepath)Write netlist in YAML.
write_netlist_dot
([filepath])Write netlist graph in DOT format.
write_oas
([gdspath, gdsdir])Write component to GDS and returns gdspath.
write_stl
(filepath[, layer_stack, ...])Write a Component to STL for 3D printing.
Attributes
bbox
Returns the bounding box of the ComponentReference.
center
Returns the center of the bounding box.
labels
layers
Returns a set of the Layers in the Component.
metadata
metadata_child
Returns metadata from child if any, Otherwise returns component own.
name
named_references
paths
polygons
ports_layer
portName.
references
size
Returns the (x, y) size of the bounding box.
size_info
Size info of the component.
x
Returns the x-coordinate of the center of the bounding box.
xmax
Returns the maximum x-value of the bounding box.
xmin
Returns the minimum x-value of the bounding box.
xsize
Returns the horizontal size of the bounding box.
y
Returns the y-coordinate of the center of the bounding box.
ymax
Returns the maximum y-value of the bounding box.
ymin
Returns the minimum y-value of the bounding box.
ysize
Returns the vertical size of the bounding box.