trimesh.path.exchange.svg_io

Classes:

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

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

An open or closed Bezier curve

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

A line or poly-line entity

Functions:

arc_center(points[, return_normal, return_angle])

Given three points on a 2D or 3D arc find the center, radius, normal, and angular span.

export_svg(drawing[, return_path, layers])

Export a Path2D object into an SVG file.

parse_path(pathdef[, current_pos])

planar_matrix([offset, theta, point, scale])

2D homogeonous transformation matrix.

svg_to_path(file_obj[, file_type])

Load an SVG file into a Path2D object.

transform_points(points, matrix[, translate])

Returns points rotated by a homogeneous transformation matrix.

transform_to_matrices(transform)

Convert an SVG transform string to an array of matrices.

trimesh.path.exchange.svg_io.export_svg(drawing, return_path=False, layers=None, **kwargs)

Export a Path2D object into an SVG file.

Parameters
  • drawing (Path2D) – Source geometry

  • return_path (bool) – If True return only path string not wrapped in XML

  • layers (None, or [str]) – Only export specified layers

Returns

as_svg – XML formatted SVG, or path string

Return type

str

trimesh.path.exchange.svg_io.svg_to_path(file_obj, file_type=None)

Load an SVG file into a Path2D object.

Parameters
  • file_obj (open file object) – Contains SVG data

  • file_type (None) – Not used

Returns

loaded – With kwargs for Path2D constructor

Return type

dict

trimesh.path.exchange.svg_io.transform_to_matrices(transform)

Convert an SVG transform string to an array of matrices.

i.e. “rotate(-10 50 100)

translate(-36 45.5) skewX(40) scale(1 0.5)”

Parameters

transform (str) – Contains transformation information in SVG form

Returns

matrices – Multiple transformation matrices from input transform string

Return type

(n, 3, 3) float