go-bim is a small collection of Go packages for building exchange formats. Right now it covers IFC, IDS, and ST-Bridge.
Import github.com/Code-Hex/go-bim/ifc when you need to read IFC STEP physical
files, keep the raw parameter structure intact, load embedded EXPRESS schemas,
bind instance arguments to schema attributes, or run schema-backed validation.
Supported IFC releases:
IFC2X3_TC1IFC4_ADD2_TC1IFC4X3_ADD2
Import github.com/Code-Hex/go-bim/ids when you need a strict IDS parser. It
keeps simpleValue and xs:restriction data intact, preserves
xsi:schemaLocation, and checks namespace rules, ordering, cardinality, and
property dataType constraints.
The package supports the official IDS 1.0.0 release and still recognizes the
older 0.9.7 candidate schema location because upstream example files still
use it.
Import github.com/Code-Hex/go-bim/stbridge when you need to read ST-Bridge
documents, including legacy 1.x .stb files, inspect the raw XML tree, or
work with embedded schema metadata for the published 2.x XSD files.
The package also ships a typed view layer and generated names so common sections and attributes are easier to reach from an editor.
Supported ST-Bridge versions:
- legacy
1.x 2.0.02.0.12.0.22.1.0
go get github.com/Code-Hex/go-bim@latestParse an IFC file and run schema validation:
package main
import (
"fmt"
"log"
"github.com/Code-Hex/go-bim/ifc"
)
func main() {
doc, err := ifc.ParseFile("model.ifc")
if err != nil {
log.Fatal(err)
}
fmt.Println(doc.Version)
report, err := ifc.Validate(doc)
if err != nil {
log.Fatal(err)
}
if !report.Valid() {
for _, finding := range report.Findings {
fmt.Printf("#%d %s: %s\n", finding.InstanceID, finding.Code, finding.Message)
}
}
}Parse an IDS file and inspect the declared specifications:
package main
import (
"fmt"
"log"
"github.com/Code-Hex/go-bim/ids"
)
func main() {
doc, err := ids.ParseFile("requirements.ids")
if err != nil {
log.Fatal(err)
}
fmt.Println(doc.Version)
for _, spec := range doc.Specifications {
fmt.Println(spec.Name, spec.IFCVersions.Strings())
}
}Parse a ST-Bridge file and inspect the common section:
package main
import (
"fmt"
"log"
"github.com/Code-Hex/go-bim/stbridge"
)
func main() {
doc, err := stbridge.ParseFile("model.stb")
if err != nil {
log.Fatal(err)
}
projectName, _ := doc.View().Common().ProjectName()
fmt.Println(doc.Version)
fmt.Println(projectName)
schema, err := doc.Schema()
if err == nil {
root, _ := schema.Element(stbridge.Element_ST_BRIDGE)
fmt.Println(len(root.ContentModel.Children))
}
}This repository keeps a few reference sets in-tree because the parsers and tests need stable fixtures.
ifc/reference/express/**contains copied official IFC EXPRESS schemasids/reference/official/**contains copied IDS reference text, XSD, and selected example filesstbridge/reference/**contains ST-Bridge XSD files, transcription notes, and source notes imported with thestbridgepackagestbridge/testdata/samples/**contains ST-Bridge sample files used by tests
The fetch scripts live in scripts/:
scripts/fetch_ifc_references.shscripts/fetch_ids_references.sh
The test surface is split by package.
go test ./ifc ./ids ./stbridgeIf you touch vendored reference data, rerun the matching fetch script and keep
the source notes up to date. The stbridge package keeps its own provenance
notes under stbridge/reference/sources/ and stbridge/reference/SOURCES.txt.
The Go code in this repository is under MIT.
Some reference material is not. These paths are excluded from the repository MIT license:
ifc/reference/express/**ids/reference/official/**stbridge/reference/**stbridge/testdata/samples/**
See LICENSE and THIRD_PARTY_NOTICES.md.