.. _Creating cross section images: Creating cross section images ============================= Vertical cross-section images of layouts can be created using the `XSection plugin `_ for KLayout. To use it, install the XSection plugin from ``KLayout -> Tools -> Manage packages``. .. note:: XSection only works with the default KLayout setup, secondary environments are not yet supported. KLayout GUI XSection tool ------------------------- Once XSection plugin is installed in KLayout, a "XSection" ruler tool is available as a scroll option for the Ruler tool. 1. Use the Ruler tool in KLayout to choose the cuts along which the vertical cross-sections are created. Select the "XSection" ruler type if you want to use other rulers for measurements. 2. To create the cross-sections: ``Tools -> XSection scripts -> Run script -> example.xs`` XSection call in KQC code ------------------------- XSection plugin can be called from python code to automate cross-section geometry generation for simulation files. :git_url:`klayout_package/python/kqcircuits/simulations/export/xsection/xsection_export.py` includes - ``create_xsections_from_simulations``, a high level method to take a cross-section for each simulation object using two ``DPoint`` values - ``xsection_call``, a low level method requiring a path to the input and output OAS files, two ``DPoint`` values and, optionally, a path to a process file. If :git_url:`xsection/kqc_process.xs` process file is used, make sure to provide a path to the parameters json file as well. An example of using XSection tool to produce cross-section simulation files is demonstrated in :git_url:`klayout_package/python/scripts/simulations/waveguides_sim_xsection.py` .. note:: XSection 1.7 does not work immediately after package install due to the improvement to backwards compatibility with older Ruby versions. To mitigate the issue, you need to make a change in the XSection code. From you KLayout environment directory, open ``.klayout/salt/xsection/ruby/xsection_script.rb`` file in editor and change line 200 from ``pts << [[[ p1, p2 ]]]`` to ``pts << [[ p1, p2 ]]`` Process files (.xs) ------------------- The process by which the actual physical shapes are created from the layout layers is defined in ``.xs`` files. The xsection folder in KQC contains two process files: 1. Lightweight example process file :git_url:`xsection/example.xs`, intended for taking cross-sections using a KLayout GUI tool 2. :git_url:`xsection/kqc_process.xs` intended only for use by a ``create_xsections_from_simulations`` call in KQC code Information about writing the ``.xs`` files can be found in the following pages: - https://klayoutmatthias.github.io/xsection/DocIntro - https://klayoutmatthias.github.io/xsection/DocReference - https://klayoutmatthias.github.io/xsection/DocGrow - https://klayoutmatthias.github.io/xsection/DocEtch