threemf

package
v1.17.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2026 License: BSD-3-Clause Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package threemf reads 3MF files (SPEC §28.5) into a model.Model: the core specification of the 3D Manufacturing Format, a zip archive whose model part (3D/3dmodel.model, found through the package's relationships) is XML, and the base materials and colors of its materials extension.

Objects with a mesh become meshes (one for each material of its triangles; colors of a color group are vertex colors, and the base material of a triangle is the material of its mesh), and objects with components become nodes with children. Every build item is a top node, with the transform of the item; an object that is used several times is built once, and its meshes are shared. The unit of the file is model.Model.Units; the positions are not scaled. Beam lattices, slices, production paths and textures are not read: a required extension that is not read is an error, one that is only used is left out with one line in the log.

Index

Constants

View Source
const TagThreeMFInvalid = "ThreeMFInvalid"

TagThreeMFInvalid is the tag of the error of a file that is not a valid 3MF file: an archive that is not a zip, a package with no model part, XML that is not well formed, a reference to an object or a property that is not there, an index outside the vertices, a required extension that is not read, a model with no item to build. The metadata has "reason" (a short fixed phrase) and "part" (the part of the archive), and for XML "line" and "column".

Flutter: no counterpart

Variables

This section is empty.

Functions

func Decode

func Decode(ctx context.Context, r io.Reader, opts ...Options) (*model.Model, error)

Decode reads a 3MF file from r. It checks ctx while it reads and parses.

It fails with model.TagModelReadFailed when the reader fails or ctx is done, and with TagThreeMFInvalid for a file that is not 3MF.

Flutter: no counterpart

func Load

func Load(ctx context.Context, fsys fs.FS, name string, opts ...Options) (*model.Model, error)

Load reads the 3MF file name of fsys. The model's name is the file's base name without its extension, unless the options give one.

Flutter: no counterpart

Types

type Options

type Options struct {
	// Name is the name of the model. Load sets the base name of the file when it is empty.
	Name string
	// Float64 keeps the positions in float64 when some of them have more digits than a float32 holds.
	Float64 bool
	// MaxModelBytes is the most that the model part may be once it is unpacked; a part that is larger is an error (a small archive
	// can unpack to any size). Zero is 1 GiB.
	MaxModelBytes int64
	// Logger gets the notes of the loader (the parts that are not read, the triangles that were dropped); slog.Default() when nil.
	Logger *slog.Logger
}

Options are the options of Decode and Load.

Flutter: no counterpart

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL