replay_edits

photonforge.live_viewer.replay_edits(component, edits, library=None)[source]

Make, on a component a script has just built, the edits made to it in a LiveViewer.

The viewer writes each edit down as a small command, such as “move instance 3 by 10 µm”. This runs those commands again, in order, on the design the script builds, through the same editor that made them in the viewer, so the design comes out as it was left there, routes and all, the schematic’s arrangement too. Each instance is named by its place among the component’s references as the script built it, so the script must still build them in that order. Run it once on each design the script builds: run again on the same design, it makes every edit again, as running any edits twice would.

Parameters:
  • component (Component) – The design as the script builds it.

  • edits (Sequence[dict]) – The recorded edits: viewer.changes() itself, its commands, the EDITS list of a saved edits file, or the text changes.replay() gives.

  • library (dict | None) – Only needed when an edit placed a cell from the viewer’s Component Library: the same cells you gave viewer.add_to_component_library, under the same names, as {name: cell} (a cell, a function that returns one, or (either, category)).

Returns:

What could not be done, in words; empty when every edit was made.

Raises:

TypeError – edits holds something that is not an edit. Nothing is changed then.

Return type:

list[str]

Example

>>> chip = build()
>>> problems = replay_edits(chip, viewer.changes())