trimesh.path.exchange.dxf

trimesh.path.exchange.dxf.bulge_to_arcs(lines, bulge, bulge_idx, is_closed=False, metadata=None)

Polylines can have “vertex bulge,” which means the polyline has an arc tangent to segments, rather than meeting at a vertex.

From Autodesk reference: The bulge is the tangent of one fourth the included angle for an arc segment, made negative if the arc goes clockwise from the start point to the endpoint. A bulge of 0 indicates a straight segment, and a bulge of 1 is a semicircle.

Parameters
  • lines ((n, 2) float) – Polyline vertices in order

  • bulge ((m,) float) – Vertex bulge value

  • bulge_idx ((m,) float) – Which index of lines is bulge associated with

  • is_closed (bool) – Is segment closed

  • metadata (None, or dict) – Entity metadata to add

Returns

  • vertices ((a, 2) float) – New vertices for poly-arc

  • entities ((b,) entities.Entity) – New entities, either line or arc

trimesh.path.exchange.dxf.convert_entities(blob, blob_raw=None, blocks=None, return_name=False)

Convert a chunk of entities into trimesh entities.

Parameters
  • blob ((n, 2) str) – Blob of entities uppercased

  • blob_raw ((n, 2) str) – Blob of entities not uppercased

  • blocks (None or dict) – Blocks referenced by INSERT entities

  • return_name (bool) – If True return the first ‘2’ value

trimesh.path.exchange.dxf.export_dxf(path, only_layers=None)

Export a 2D path object to a DXF file.

Parameters
  • path (trimesh.path.path.Path2D) – Input geometry to export

  • only_layers (None or set) – If passed only export the layers specified

Returns

export – Path formatted as a DXF file

Return type

str

trimesh.path.exchange.dxf.get_key(blob, field, code)

Given a loaded (n, 2) blob and a field name get a value by code.

trimesh.path.exchange.dxf.load_dwg(file_obj, **kwargs)

Load DWG files by converting them to DXF files using TeighaFileConverter.

Parameters

file_obj (file- like object) –

Returns

loaded – kwargs for a Path2D constructor

Return type

dict

trimesh.path.exchange.dxf.load_dxf(file_obj, **kwargs)

Load a DXF file to a dictionary containing vertices and entities.

Parameters

file_obj (file or file- like object (has object.read method)) –

Returns

result

Return type

dict, keys are entities, vertices and metadata