niess.brep¶
Solid geometry from the niess object tree, as a build123d assembly or a STEP file. See Export an instrument to CAD for the task-oriented guide and the CAD gallery for what each component is drawn as.
brep
¶
Solid geometry -- STEP/CAD -- from a niess instrument.
from niess.instrument import Instrument, Mount
from niess.brep import save_step
save_step(instrument, 'instrument.step')
Reads the tree: a component's position and orientation are on the component, as scipp Variables, and composing them with the frame it hangs from is arithmetic. There is no other route -- niess draws niess instruments.
Importing this module registers the shape builders, which is what to_assembly resolves
against.
Modules:
-
assembly–Solid geometry, built from the tree.
-
builders–The shape each component is drawn as.
Classes:
-
NiessBRepRegistry–Shape-builder lookup for the CAD target.
-
Subject–What a shape builder is given.
Functions:
-
save_step–Write an instrument to a STEP file.
-
to_assembly–Build a labelled
build123dassembly of everything with a shape.
NiessBRepRegistry
¶
Bases: NiessRegistry
Shape-builder lookup for the CAD target.
Resolves either way: :meth:resolve_for_object for a niess object the walk handed
over, :meth:resolve_builder for an emitted instance. The builders take a
:class:Subject and do not know which happened.
Source code in src/niess/brep/assembly.py
Subject
dataclass
¶
What a shape builder is given.
The builders were written against the McCode parameters a component reports, so that is what they still take, alongside the object itself -- reading a dimension off it beats reading the four edges it emits as.
save_step
¶
save_step(instrument, path, registry=None, parameters: dict | None = None) -> None
Write an instrument to a STEP file.
Source code in src/niess/brep/assembly.py
to_assembly
¶
to_assembly(instrument, registry=None, parameters: dict | None = None)
Build a labelled build123d assembly of everything with a shape.
The assembly follows the tree: each component is a child labelled with its emitted
name, inside a group for each node that holds more than one shaped thing --
tank > channel_3 > channel_3_1_analyzer -- so a viewer can show, hide
and pick them one at a time. A node holding just one is not a group of its own.
Every node is placed, whether or not it has a shape: a frame draws nothing and is still what the things hanging from it are measured against.
parameters sets the run-time knobs frames turn by, by name -- BIFROST's
{'detector_tank_angle': 60, 'sample_rotation': 30}, in degrees. A knob not
given is drawn at its declared default; a name no frame turns by is an error.