The ``pyedb.extensions.dxf_swap_backend`` library ================================================= .. py:module:: pyedb.extensions.dxf_swap_backend Summary ------- .. py:currentmodule:: dxf_swap_backend .. tab-set:: .. tab-item:: Functions .. list-table:: :header-rows: 0 :widths: auto * - :py:obj:`~create_polygon_from_dxf` - Create a polygon primitive in the EDB layout from the first entity * - :py:obj:`~swap_polygon_with_dxf` - Replace an existing polygon on a given layer with a new polygon * - :py:obj:`~swap_polygon_with_dxf_center_point` - Replace an existing polygon on a given layer with a new polygon Module detail ------------- .. py:function:: create_polygon_from_dxf(edb: pyedb.Edb, dxf_path: str, layer_name: str) -> pyedb.grpc.database.primitive.primitive.Primitive Create a polygon primitive in the EDB layout from the first entity found in a DXF file. :Parameters: **edb** : :obj:`Edb` An active EDB (Electronics Database) instance that the polygon will be added to. **dxf_path** : :class:`python:str` Absolute or relative path to the DXF file containing the geometry to import. **layer_name** : :class:`python:str` Name of the EDB layer on which the polygon will be created. :Returns: :obj:`Primitive` The newly created polygon primitive object. .. rubric:: Notes * Only the first entity in the DXF modelspace is used; all other entities are ignored. * Coordinates in the DXF are assumed to be in **microns** and are divided by 1000 to convert to **millimetres** before being passed to EDB. * The resulting polygon is **not** translated or rotated; it is placed exactly as defined in the DXF (after scaling). .. rubric:: Examples >>> edb = Edb(edbpath="my_design.aedb") >>> poly = create_polygon_from_dxf(edb, dxf_path="outline.dxf", layer_name="Outline") >>> print(poly) .. !! processed by numpydoc !! .. py:function:: swap_polygon_with_dxf(edb: pyedb.Edb, dxf_path: str, layer_name: str, point_dxf: List[str], point_aedt: List[str]) Replace an existing polygon on a given layer with a new polygon imported from a DXF file, aligning the two geometries via reference points. :Parameters: **edb** : :obj:`Edb` An active EDB instance. **dxf_path** : :class:`python:str` Path to the DXF file that contains the replacement geometry. **layer_name** : :class:`python:str` Layer on which the old polygon will be deleted and the new one created. **point_dxf** : :obj:`List`\[:class:`python:str`] Two-element list of strings specifying the **reference point** inside the DXF geometry (units: **mm**). Example: ``["-1.5", "4.2"]``. **point_aedt** : :obj:`List`\[:class:`python:str`] Two-element list of strings specifying the **target location** in the EDB layout where the DXF reference point should land (units: **mm**). Example: ["12.0", "7.5"]. :Returns: :data:`python:None` The function operates in-place on the provided EDB instance. .. rubric:: Notes * Only the first entity in the DXF modelspace is used. * Both input points are internally converted to **metres** before computing the translation vector. * The translation vector is then scaled back to **millimetres** and expressed as strings with an "mm" suffix, as required by the EDB move API. .. rubric:: Examples >>> edb = Edb(edbpath="design.aedb") >>> swap_polygon_with_dxf( ... edb, ... dxf_path="new_outline.dxf", ... layer_name="Outline", ... point_dxf=["0", "0"], # Origin in DXF ... point_aedt=["10", "5"], # Where DXF origin should land ... ) >>> edb.save() .. !! processed by numpydoc !! .. py:function:: swap_polygon_with_dxf_center_point(edb: pyedb.Edb, dxf_path: str, layer_name: str, point_aedt: List[str]) Replace an existing polygon on a given layer with a new polygon imported from a DXF file, aligning the two geometries via reference points. Uses the center point of the DXF polygon as reference (not an input point). :Parameters: **edb** : :obj:`Edb` An active EDB instance. **dxf_path** : :class:`python:str` Path to the DXF file that contains the replacement geometry. **layer_name** : :class:`python:str` Layer on which the old polygon will be deleted and the new one created. **point_aedt** : :obj:`List`\[:class:`python:str`] Two-element list of strings specifying the **target location** in the EDB layout where the DXF reference point should land (units: **mm**). Example: ["12.0", "7.5"]. :Returns: :data:`python:None` The function operates in-place on the provided EDB instance. .. rubric:: Notes * Only the first entity in the DXF modelspace is used. * Both input points are internally converted to **metres** before computing the translation vector. * The translation vector is then scaled back to **millimetres** and expressed as strings with an "mm" suffix, as required by the EDB move API. .. rubric:: Examples >>> edb = Edb(edbpath="design.aedb") >>> swap_polygon_with_dxf( ... edb, ... dxf_path="new_outline.dxf", ... layer_name="Outline", ... point_aedt=["10", "5"], # Where DXF origin should land ... ) >>> edb.save() .. !! processed by numpydoc !!