Skip to main content

Crate stepq

Crate stepq 

Source
Expand description

§stepq

Query, inspect, split and reshape STEP (ISO 10303-21) files.

stepq works on the entity graph of a Part 21 file. It never evaluates geometry: there is no tessellation, no volume, no healing. Everything it does — splitting assemblies, extracting a bill of materials, validating structure — is a graph operation over the original entity instances, which are preserved byte-for-byte.

The crate is a library first. The stepq command-line tool is built from the same code behind the cli feature (enabled by default). Library users can depend on it with default-features = false.

§Pipeline

Every command is built from the same four steps: p21::parse the bytes into an Exchange, index its references with a model::Graph, ask questions through the record and parameter views, and write a selection back out with a p21::Writer.

use stepq::model::Graph;
use stepq::p21::{Numbering, Writer, parse};

let src = b"ISO-10303-21;HEADER;FILE_SCHEMA(('AP242'));ENDSEC;DATA;
#1=PRODUCT('p1','bracket','',(#2));
#2=PRODUCT_CONTEXT('',#3,'mechanical');
#3=APPLICATION_CONTEXT('design');
#4=PRODUCT_DEFINITION_FORMATION('','',#1);
ENDSEC;END-ISO-10303-21;";

let graph = Graph::new(parse(src)?)?;
let exchange = graph.exchange();

// Find instances by type and read their attributes.
let product = exchange.instances_of("PRODUCT").next().unwrap();
let record = exchange.records(graph.instance(product)).next().unwrap();
let name = record.param(1).and_then(|p| p.literal()).unwrap().decode()?;
assert_eq!(name, "bracket");

// Follow references backwards: the formation points at the product.
let users: Vec<u64> = graph
    .referenced_by(product)
    .iter()
    .map(|&node| graph.instance(node).id)
    .collect();
assert_eq!(users, [4]);

// Write the product and what it refers to, renumbered from #1.
let mut out = Vec::new();
Writer::new(exchange)
    .numbering(Numbering::Dense)
    .write_selection([0, 1, 2], &mut out)?;

§Commands and modules

Each stepq command is a thin front end over a library function:

docs/COMMANDS.md in the repository documents every command and option.

§Features

§Status

Pre-1.0. The public API will change. See ROADMAP.md in the repository for what is planned and docs/ARCHITECTURE.md for the design decisions this crate is built on.

Re-exports§

pub use error::Error;
pub use error::Result;

Modules§

assemble
Resolving external references: the inverse of stepq split --master.
diff
A structural comparison of two STEP files.
error
Error types shared by the whole crate.
express
EXPRESS (ISO 10303-11) schemas, read at run time.
info
A summary of a STEP file: header, units, counts and entity types.
lint
Structural problems in a STEP file, found without a geometry kernel.
model
The in-memory entity graph.
p21
ISO 10303-21 (“Part 21”) clear-text encoding.
pmi
Semantic PMI: geometric tolerances, dimensions and datums.
props
Product properties: user-defined attributes, validation properties and persistent identifiers.
strip
Removing personal and identifying text from a STEP file.