trimesh.path.exchange.dxf

Classes:

Arc(points[, closed, layer, color])

BSpline(points, knots[, layer])

An open or closed B- Spline.

Line(points[, closed, layer, color])

A line or poly-line entity

Template(template)

A string class for supporting $-substitutions.

Text(origin, text[, height, vector, normal, …])

Text to annotate a 2D or 3D path.

Functions:

bulge_to_arcs(lines, bulge, bulge_idx[, …])

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

convert_entities(blob[, blob_raw, blocks, …])

Convert a chunk of entities into trimesh entities.

export_dxf(path[, layers])

Export a 2D path object to a DXF file.

find_executable(executable[, path])

Tries to find ‘executable’ in the directories listed in ‘path’.

get_key(blob, field, code)

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

load_dwg(file_obj, **kwargs)

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

load_dxf(file_obj, **kwargs)

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

to_threepoint(center, radius[, angles])

For 2D arcs, given a center and radius convert them to three points on the arc.

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, layers=None)

Export a 2D path object to a DXF file.

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

  • layers (None, set or iterable) – 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