trimesh.path.exchange.svg_io module

trimesh.path.exchange.svg_io.export_svg(drawing, return_path=False, only_layers=None, digits=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

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

  • digits (None or int) – Number of digits for floating point values

Returns:

as_svg – XML formatted SVG, or path string

Return type:

str

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

Load an SVG file into a Path2D object.

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

  • file_type (None) – Not used

  • path_string (None or str) – If passed, parse a single path string and ignore file_obj.

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