The use of classes in **fnpcell** (generating components) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The following code is taken from ``gpdk`` > ``components`` > ``bend`` > ``bend_bezier.py`` and belongs to the part that uses the ``BendBezier`` class to create the device and generate the layout:: if __name__ == "__main__": from pathlib import Path gds_file = Path(__file__).parent / "local" / Path(__file__).with_suffix(".gds").name library = fp.Library() TECH = get_technology() # ======================================================================= # fmt: off library += BendBezier() library += BendBezier(name="q", start=(0, 0), controls=[(31, 30)], end=(60, 0), waveguide_type=TECH.WG.FWG.C.WIRE) # library += BendBezier(name="c", start=(0, 0), controls=[(0, 30), (60, 30)], end=(60, 0), waveguide_type=TECH.WG.FWG.C.WIRE, transform=fp.translate(0, 40)) # fmt: on # ============================================================= fp.export_gds(library, file=gds_file) # fp.plot(library) Section Script Description ---------------------------- #. Import the OS path structure, create a local folder in the current folder to save the generated GDS files, and call ``fp.Library`` module in **PhotoCAD** to display the generated files and export the GDS files:: from pathlib import Path #. Call ``get_technology`` method get information about the layout design process:: TECH = get_technology() #. Generate devices using the ``BendBezier`` class through the library implementation in the function module:: library += BendBezier() library += BendBezier(name="q", start=(0, 0), controls=[(30, 30)], end=(60, 0), waveguide_type=TECH.WG.FWG.C.WIRE) library += BendBezier(name="c", start=(0, 0), controls=[(0, 30), (60, 30)], end=(60, 0), waveguide_type=TECH.WG.FWG.C.WIRE, transform=fp.translate(0, 40)) In this section the user can set the parameters in the ``BendBezier`` class. The parameters contain not only the parameters of the device itself for layout generation but also the relative position parameters for setting the position of the layout cell relative to the origin when called hierarchically. The above code creates three devices using the ``BendBezier()`` class with three lines of library statements, using the default name ``BendBezier`` and two user-defined names ``q`` and ``c``, respectively, which are prefixed with ``BendBezier_`` by default when generating the layout, as follows ``BendBezier_q``, ``BendBezier_c``. The above ``BendBezier`` example shows that in ``gpdk`` > ``components``, each parameterized components can be generated by a python script, which first defines the component by class, second defines the structure by variable parameters, and then passes the parameters to ``fnpcell`` to achieve component design and layout generation.