Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

3D Manufacturing Format (3MF) implementation for Go

License

NotificationsYou must be signed in to change notification settings

HPInc/go3mf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PkgGoDevBuild StatusGo Report CardCoverage StatusLicense

go3mf

The 3D Manufacturing Format (3MF) is a 3D printing format that allows design applications to send full-fidelity 3D models to a mix of other applications, platforms, services and printers. The 3MF specification allows companies to focus on innovation, rather than on basic interoperability issues, and it is engineered to avoid the problems associated with other 3D file formats. Detailed info about the 3MF specification can be fint at3mf.io.

Features

  • High parsing speed and moderate memory consumption
  • Complete 3MF Core spec implementation.
  • Clean API.
  • STL importer
  • Spec conformance validation
  • Robust implementation with full coverage and validated against real cases.
  • Extensions
    • Support custom and private extensions.
    • Support lossless decoding and encoding of unknown extensions.
    • spec_production.
    • spec_slice.
    • spec_beamlattice.
    • spec_materials, missing the display resources.

Examples

Read from file

package mainimport ("fmt""github.com/hpinc/go3mf")funcmain() {varmodel go3mf.Modelr,_:=go3mf.OpenReader("/testdata/cube.3mf")r.Decode(&model)for_,item:=rangemodel.Build.Items {fmt.Println("item:",*item)obj,_:=model.FindObject(item.ObjectPath(),item.ObjectID)fmt.Println("object:",*obj)ifobj.Mesh!=nil {for_,t:=rangeobj.Mesh.Triangles.Triangle {fmt.Println(t)        }for_,v:=rangeobj.Mesh.Vertices.Vertex {fmt.Println(v.X(),v.Y(),v.Z())        }      }    }}

Read from HTTP body

package mainimport ("bytes""fmt""io/ioutil""net/http""github.com/hpinc/go3mf")funcmain() {resp,_:=http.Get("zip file url")deferresp.Body.Close()body,_:=ioutil.ReadAll(resp.Body)varmodel go3mf.Modelr,_:=go3mf.NewDecoder(bytes.NewReader(body),int64(len(body)))r.Decode(&model)fmt.Println(model)}

Write to file

package mainimport ("fmt""os""github.com/hpinc/go3mf")funcmain() {varmodel go3mf.Modelw,_:=go3mf.CreateWriter("/testdata/cube.3mf")w.Encode(&model)w.Close()}

Spec usage

Specs are automatically registered when importing them as a side effect of the init function.

package mainimport ("fmt""github.com/hpinc/go3mf""github.com/hpinc/go3mf/material""github.com/hpinc/go3mf/production")funcmain() {varmodel go3mf.Modelr,_:=go3mf.OpenReader("/testdata/cube.3mf")r.Decode(&model)fmt.Println(production.GetBuildAttr(&model.Build).UUID)model.Resources.Assets=append(model.Resources.Assets,&materials.ColorGroup{ID:10,Colors: []color.RGBA{{R:255,G:255,B:255,A:255}},    }}

[8]ページ先頭

©2009-2025 Movatter.jp