Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

STEP import

SolidCraft reads STEP (ISO 10303-21; AP203, AP214 and AP242 geometry) with its own reader in crates/kernel/src/step_in (written from the public standards; no third-party STEP code). The reader tells which protocol a file declares, and for AP242 which edition, 1 to 4, from the identifier after the schema name (solidcore-record’s step::protocol). A file is read the same whatever it declares: an AP242 file without a known edition, or a file with no known schema, is read with a warning. A STEP file becomes an Import base feature on the timeline: it holds the file’s B-rep (the STEP text is kept in the design, so the design reopens without the file) and later features — fillets, holes, cuts sketched on its faces, shells — build on its bodies.

  • Open: File → Open (doc.open) accepts .step/.stp in any case and starts a new design; solidcraft part.step; solidcraft-cli eval part.step, solidcraft-cli run script.json --in part.step; the MCP open tool.
  • Insert into the current design: File → Insert STEP… or SOLID → INSERT (file.insert_step {path}).
  • Drag and drop a STEP file on the window: inserted when the design has features, opened otherwise.

Inspect one body from a script

With SolidCraft’s STEP reader, pass body_index to file.insert_step or doc.open. The index starts at zero and follows the reader’s body order. Each placement of a repeated part has its own index, and unreadable bodies still count. The reader scans the file’s structure and converts only the selected body, keeping its placement. An out-of-range index or an unreadable selected body returns an error. Omit the index to import all bodies.

This example selects the second body in frame.step, which imports as Beam. Use the body name from bodies[0] in the import reply as model.faces’s body. Save the script as faces.json and run solidcraft-cli run faces.json --results. Run solidcraft-cli eval faces.json to report the selected body’s measurements.

{
  "commands": [
    {"command": "file.insert_step", "params": {"path": "frame.step", "body_index": 1}},
    {"command": "model.faces", "params": {"body": "Beam"}}
  ]
}

Imports are components

Every import (STEP, IGES, 3MF, STL, OBJ; inserted, dropped, opened as a new design, or run as file.insert_step, file.insert_mesh or doc.open from a script, the CLI or MCP) becomes a new component named after the file (bracket.step → component bracket), placed in the active component at the file’s origin. The Import feature belongs to it, so the file’s bodies never land loose next to your own. Opening a file as a design makes the component too, so the browser shows the file’s name. The command’s reply reports it: component (id), component_name and occurrence. With the top level (or any component above the part) active, an extrude, revolve or press-pull from a sketch on a part’s face cuts or joins that part’s body in its own component, wherever the part is placed, and every placement of the part shows the change. It is refused, with the reason, for a part linked to another design and for a face on a further placement of a part placed more than once (activate that placement to change it there).

A STEP assembly keeps its structure: each product under the file’s root becomes a component nested under the import’s, named after the product, at the place the file gives it. IGES groups and subfigures become nested components the same way. A part (or sub-assembly) the file places more than once becomes one component with an occurrence per placement: the Import feature builds the part once and skips the file’s later copies (skip in the feature, format 22), and the occurrences show it everywhere else. Placements that are scaled, mirrored or otherwise non-rigid keep their geometry in place in the parent component. The reply adds subcomponents (how many components were made below the import’s) and rigid_members (how many occurrences its rigid group holds).

A part bought in, such as a circuit board’s 3D model, never moves inside, and its structure costs hundreds of components and joints. file.insert_step with flatten: true brings every solid in as a body of the import’s own component instead: no components below it, no further occurrences, no joints and no rigid group, so the reply has no subcomponents or rigid_members. A part the file places several times becomes one body per placement, each where the file puts it (nothing is skipped). As no component says any more which part a body belongs to, each body’s name is prefixed with the outermost named product holding it below the file’s root (R63: Terminal), and a placeholder name (empty, a bare number such as a library model’s id, or the names an exporter makes up for sub-shapes, such as Open CASCADE’s Open CASCADE STEP translator 7.5 2.1.1) gives way to its nearest named product’s. The names are stored with the Import feature, so reopening, undo and rebuilding give the same bodies.

A solid no closed B-rep can be made of comes in as open surfaces of its faces, with no volume, so clearance and interference checks do not see it. file.insert_step (with or without split_to_files) lists each such body in surface_bodies, as {name, reason?} with the reason the import gives; the key is absent when every body is a solid. A face whose loop encloses no (u, v) area and whose neighbours coincide along its sides (a face of no width or no size) is left out instead, the faces beside it meeting where it was, and the solid stays closed, with a note saying how many faces were left out (naming the face for a face of no size or of several coincident pairs of edges).

The Browser reuses body, sketch and construction-plane membership, child lists and resolved placements while the camera moves. Large assemblies keep their tree open without resolving every part and folder again on each frame. Geometry edits, assembly changes and uncaptured or reverted positions refresh those queries; selection, visibility and locking are read live.

Hover picking pauses while the mouse moves the view and resumes when navigation stops. A 3D mouse moving the view leaves it on: the pointer hand is free, so preselection and clicks keep working while the other hand turns the view. Picking uses the current camera and the cached body bounds directly in model order, so finding each body’s bounds does not scan the assembly again.

Hovering an assembly’s Browser row retains its whole-body highlight buffers during rotation, panning and zoom; the GPU transforms those buffers with the camera. The origin and construction widgets resize independently. Whole-body highlight generation scans each mesh once rather than scanning it again for every face. Sketch profile feedback still updates its projected curves and lift toward the eye as the view changes.

The contents of an imported assembly are rigid by default: one rigid group (joint.list’s rigid_groups, one row per import however many parts it has) holds each part where the file put it in its parent, so moving the import’s component moves everything, and an inner part doesn’t move on its own; joint degrees of freedom count the whole import as one body. A part you place inside the import’s component later is not in its group and moves on its own. To joint the parts one by one, release them with Unlock Contents on the component’s browser menu (component.unlock {component}), one undo step. Undo takes a whole import away in one step.

Designs saved before imports made components keep their Import where it is (no component is made for it) and rebuild as they did.

Read: manifold solid breps (with voids), faceted breps, shell-based surface models; planes, cylinders, cones, spheres, tori, B-spline and rational B-spline surfaces (with knots, Bézier, uniform, quasi-uniform), surfaces of revolution and linear extrusion, trimmed surfaces; lines, circles, ellipses, hyperbolas and parabolas (as exact rational curves, which export writes back as exact rational B-splines), B-spline curves, polylines, trimmed/surface/seam curves; length and angle units (SI prefixes, conversion-based units such as inches); product names (meaningful solid names are kept, placeholders use part names; names below chooses); surface colours; assemblies (next-assembly-usage occurrences placed by item-defined transformations, and mapped items) — the product tree is kept in the feature and becomes the import’s components (above). Files are untrusted: sizes, entity counts and nesting are capped and every kernel call is guarded. What cannot be read becomes a warning on the feature (a face left out gives an open body); not read yet: offset surfaces, pcurve-only edges.

Extruded circular and elliptical faces keep their profile’s parameter seam outside the face trim, or on an explicit seam edge. Narrow faces such as rounded gear tooth tips therefore stay narrow through the full thickness instead of wrapping around the supporting ellipse in the middle.

Files from other CAD systems

Files from different systems differ in which way is up and in what they call their solids. doc.open, file.insert_step and the MCP open tool take two options for STEP and IGES files; without them a file comes in as written.

  • up: "z" (the default) keeps the file’s axes. Many systems write Y up, so such a part lies on its back in SolidCraft’s Z-up space. "up": "y" turns the import’s component a quarter turn about X (+90°: Y becomes Z), as the window’s “Stand it up” offer does, so an assembly’s parts and instances turn together. The import and the turn are one undo step, the reply names the turned occurrence as stand_up, and only the file’s component turns, not what is already in the design. The window offers to stand a part up after a STEP file opens unless the call said which way is up (up: "z" as well as "y") or the file came from SolidCraft, which already writes Z up. A STEP reply’s system is the originating system the file’s header names (SolidCraft for SolidCraft’s own exports). A header that names SolidWorks (in FILE_NAME’s originating system or preprocessor version, or in FILE_DESCRIPTION; for IGES, the start of the global section’s native system ID, which becomes the originating system) says the file has Y up: the reply carries exporter (SolidWorks) and exporter_up (y), and the window asks in the “Stand this part up?” dialog, which says so (“Exported by SolidWorks, which usually saves Y up”). The first opening never turns a file without asking, because the exporter may have saved it Z up; unchanged files reuse a remembered stand-up answer unless Preferences › Design › Remember stand-up answers is off; a component’s right-click menu has Placement → Turn Up Axis (Y up → Z up, Z up → Y up: a quarter turn about X, one undo step) for fixing it any time. SolidCraft’s own files say z and are left alone. Any other exporter is unknown, and such files are often upright already, so by default the window first looks at how the bodies rest: a part rests on its flat faces, so the flat area facing down Z is weighed against the larger flat area facing down or up Y (faces within 10° of the direction; one side must have at least 1.5 times the other’s, else the thinner of the box’s Y and Z sizes decides). Unless the file clearly stands upright, the window shows a small note over the view (“Did this part open the wrong way up?” with Stand it up and Close) that goes by itself after 10 seconds and never blocks input; a file that clearly stands upright gets nothing, and an unclear shape still gets the note. A SolidWorks file whose bodies clearly stand on Z already gets the note instead of the dialog, since it may have been saved Z up. Preferences › Design › “For files from unknown programs” picks the dialog for every file from another program, SolidWorks too, without looking at how it rests (Ask in a dialog, as before) or no offer (Don’t offer) instead. The dialog and the note say “assembly” when the file brought more than one body or a component tree.
  • names: "auto" (the default) keeps meaningful solid names and replaces placeholders such as Body1 or Body 2 (3) with the nearest named product, then the occurrence name if no product is named. "solid" keeps the solid’s name; "product" chooses the part’s name; "instance" chooses the assembly occurrence (Post-2), falling back to the product. If the chosen name is missing, the solid’s name remains. Repeated names are numbered (Post, Post (2)). Names are stored with the Import feature and survive reopening the design. Files without names or assembly metadata retain generated body names and a flat structure.
  • Vertices off their curves: some systems write an edge’s vertex a little beside the end of its curve, often further off than the accuracy the file declares (UNCERTAINTY_MEASURE_WITH_UNIT). A vertex up to the file’s own tolerance off, or up to 1/1000 of the model’s size (never more than 1 mm), is read as that end of the edge: the curve’s end is moved onto the vertex. A vertex further off leaves its face out, with a warning that says how far off it is. A vertex’s place on a circle or ellipse is the curve’s point nearest it, so a vertex a rounding off a very flat ellipse (radii 1000 and 0.3 mm) stays where it is along the curve.
  • Closed curves that close to the file’s tolerance: a closed B-spline or polyline whose first and last control points are one point to the file’s tolerance but not to the last digit has both made their mean (the curve moves by half the gap at most), so an edge whose vertex lies part way round it starts the curve there instead of leaving its faces out (“spline seam endpoints do not coincide”).
  • Edges along a closed surface’s seam: an edge’s 2D curve on a face’s surface that closes on itself can come out past the seam by its fit’s rounding (4·10⁻¹¹ of a period of 0.02 in one file) while the edges beside it end on the seam. It is put on the seam, so it stays beside them instead of moving a whole turn to the seam’s other side and leaving the face out (“on another period”, “a trim crossing the base period”).
  • A narrow strip closed by one vertex: some systems end a strip narrower than their tolerance (0.03 mm wide in one file) with a single vertex in the middle of its end instead of an edge across it. Where the vertex’s tolerance covers the whole of that end (checked exactly on the surface), the face’s boundary runs across it there instead of the face being left out (“a loop that jumps across its spline surface’s v range”).
  • A hole that touches the edge of its face: some systems write a hole whose rim touches its face’s outer edge at exactly one point (a hole tangent to a wall, a slot cut to a boundary), or two holes that touch, as loops of their own that share a vertex (ISO 10303-42 has a face’s bounds share no vertex: such a boundary is one loop through the vertex twice). SMLib takes no face whose loops share a vertex, so such a body used to come in closed and then fail its check (“Face Loops must not share a Vertex”), and every feature on it was refused. The reader makes the touching loops one loop through that vertex: the same region, faces, edges, vertices and volume, and a warning says how many loops it joined. Loops that touch at two points or more (they cut the face in two), or three or more at one point, stay as written; the warning then names the face and the point, and the body still fails its check until the source model keeps the loops apart there.
{"command": "file.insert_step", "params": {"path": "frame.step", "up": "y", "names": "instance"}}
  • split_to_files: true writes each leaf product once as a .sc part file and each assembly (including nested ones) as a .sc that links its children with component.insert_design, under split_folder (default: the STEP file’s directory). STEP (.step / .stp) only. A multi-body part that is not an assembly stays one file. Open then opens the top assembly; Insert links it into the current design. Mutually exclusive with flatten. An existing target file is refused unless overwrite: true. The reply names split_root and split_files.
{"command": "file.insert_step", "params": {"path": "machine.step", "split_to_files": true, "split_folder": "/path/to/out"}}

In automatic naming, a body labelled NONE uses its original face label when every imported face shares one meaningful label. Mixed or missing face labels keep the original body name; an explicit names: "solid" always keeps it. This only chooses the displayed body name: the source STEP is never rewritten.

Imported appearances

Imported body colours and face colours are retained through later features. Body colours remain the fallback under explicit design appearances and materials; face colours follow persistent face names. A removed face has no colour assignment to display on the resulting body.

IGES

IGES 5.3 files (.igs/.iges) open, insert and drop the same way: crates/kernel/src/iges_in.rs (written from the published specification) restates the file as STEP and the STEP reader reads it, so the feature holds STEP text (unless cadmpeg’s IGES decoder is chosen, below). Read: manifold solid B-reps (186) with their shells, faces, loops, edge and vertex lists; trimmed (144) and bounded (143) surfaces, and bare B-spline patches, sewn within their owning group into a solid by their shared edges (an open body when they do not close); groups (402 forms 1, 7, 14 and 15), subfigure definitions (308) and instances (408), retaining names, nesting and placements; lines, circular arcs, ellipses, composite curves, rational B-spline curves; planes (108, 190), cylinders, cones, spheres, tori, rational B-spline surfaces, surfaces of revolution and tabulated cylinders; transformation matrices; units; colours (314 and the predefined numbers); body names (name properties, else labels). Not read yet: ruled and offset surfaces, curves on surfaces given only in parameter space. Export (file.export to .igs) writes each body as a manifold solid B-rep on the same surfaces a STEP export uses, with its name and colour.

FreeCAD and Rhino

FreeCAD .FCStd and Rhino .3dm files open, insert and drop the same way, in the desktop app, the browser app and the CLI. They are read with cadmpeg (Apache-2.0, crates/io/src/native_cad.rs): cadmpeg detects the format from the bytes, decodes it into its neutral model (CADIR) under resource caps and checks that model. By default cadmpeg then writes the model as STEP AP214, which the STEP reader reads; the feature holds that STEP text, so the design reopens without the original file. A FreeCAD body’s intermediate shapes (each pad’s, pocket’s and tool’s, and its tip’s, which FreeCAD shows through the body) and shape binders are not imported: only the bodies come in. Losses cadmpeg reports become warnings on the feature, and a file without an importable solid is refused with a message. cadmpeg runs inside the panic guard. How much of a file is read follows cadmpeg’s support for that format (format support).

Import with cadmpeg (off by default)

Preferences › General › Import with cadmpeg (cadmpeg_import, off by default), or reader: "cadmpeg" on doc.open and file.insert_step, reads a FreeCAD or Rhino file’s solids straight from cadmpeg’s model instead, wherever they come in as an Import feature (a Rhino file, a FreeCAD file opened with history: solids, or one whose history is not rebuilt; a FreeCAD history that rebuilds comes in as features, as below, whatever the reader): solidcore-cadir reads each body’s faces, edges and vertices into B-rep records, which go through the same assembly (pcurves, seams, tolerances) and the same SMLib conversion as a STEP file’s solids. No STEP text is made; the feature holds those records, so the design reopens without the original file. A body’s placement in the file is kept when it is a rotation and a move; a body placed by a scale or a mirror, elliptical cones, composite and polygonal curves and surfaces, and faces with no boundary are refused with a warning that names the body, and the file’s other bodies still come in. (cadmpeg’s STEP writer, which the default route goes through, writes such a body unplaced and an elliptical cone as a circular one.) Hidden intermediate shapes and binders are left out as on the default route. With the switch off, and with reader: "solidcraft" (the default), the file comes in through the STEP route above.

FreeCAD feature history

A FreeCAD file’s design history is rebuilt as features by default (history: features on doc.open and file.insert_step; Preferences › General › FreeCAD files). cadmpeg decodes the file at full depth and crates/io/src/native_cad/design.rs writes one feature per FreeCAD feature, in history order, into the file’s component:

FreeCADSolidCraft
Sketcher sketch: lines, circles, arcs, pointsSketch on the same plane, with FreeCAD’s solved geometry and each constraint that keeps it (coincident, horizontal, vertical, parallel, perpendicular, tangent, equal, point on object, symmetric, midpoint, fixed, distance, horizontal and vertical distance, radius, diameter, angle); dimensions become parameters
Pad, Pocket, Part Extrusion: blind, through all, symmetric, two-sided, along the sketch normal or an edgeExtrude (new body, join, cut); a loop inside another is a hole, as FreeCAD makes faces
Revolution, Groove, Part Revolution: angle, symmetric, two-sidedRevolve
Fillet (constant radius), Chamfer (distance, two distances, distance and angle)Fillet, Chamfer on the same edges
Part and PartDesign box, cylinder, cone, sphere, torus (whole)Box, Cylinder, Cone, Sphere, Torus
Mirrored, LinearPattern (one direction), PolarPattern of featuresMirror, Pattern of the same features
Body placement, datum planes, axes and points, shape bindersapplied to the features / not rebuilt (sketches on them keep their place)

The rebuilt design is evaluated and compared with the file’s own solids: each body must have the volume, extent and centre of one of them. When a feature cannot be rebuilt (another operation, an up-to-face extent, a tapered pad, an ellipse or B-spline in a sketch, a MultiTransform, a feature after a body’s tip), SolidCraft cannot build one (some fillets) or the comparison fails, the file’s solids come in as an Import feature as before, with a warning that says why, and the file’s sketches come in beside them in the same component, made as the rebuild makes them (on their planes, with the constraints that keep their geometry, dimensions as parameters), so they can be edited and used again (history: "sketches", their ids in features_added). A sketch that cannot be read is left out with a warning. A constraint that would move FreeCAD’s geometry is left out, and a warning counts those. Expressions and spreadsheets are not carried over: the parameters hold the values FreeCAD computed. Rhino files have no such history; their solids come in as before.

Only codecs for open formats are compiled in: the workspace turns off cadmpeg’s default features and enables fcstd, rhino and step. cadmpeg’s codecs for commercial CAD formats are not built, and neither is its sat codec, which decodes ShapeManager streams with ACIS as one dialect, so ACIS .sat/.sab files are not read yet. crates/io/src/native_cad.rs is the one place cadmpeg is called.

Reading STEP with cadmpeg

A STEP file can also be read by cadmpeg’s STEP decoder instead of the reader above, to compare the two on real files: reader: "cadmpeg" on doc.open and file.insert_step, or the same Preferences › General › Import with cadmpeg switch (cadmpeg_import, off by default) that reads FreeCAD and Rhino files into records. cadmpeg decodes the file into its neutral model, which is read into B-rep records exactly as a FreeCAD or Rhino file’s is with that switch on; the Import feature keeps those records and no STEP text. An IGES file (.igs, .iges) is read the same way with that choice: cadmpeg’s IGES decoder (cadmpeg-codec-iges) decodes it into the neutral model, read into records with its bodies’ names and colours, instead of iges_in.rs restating it as STEP. cadmpeg reads manifold solid B-reps (186); it does not sew trimmed surfaces (144) into solids as SolidCraft’s reader does (each comes in as a surface body of its own), and it takes a trimmed surface’s carrier and a composite curve’s pieces only when the file marks them physically dependent, a parameter-space curve only with use flag 05, and a colour definition (314) only as an independent definition with a non-empty name or none, so a file that bends these rules comes in with fewer faces, without colours or is refused. The program that wrote the file is read as SolidCraft’s reader reads it, so a SolidCraft or SolidWorks file is recognised by its writer and offered the same stand-up: for a STEP file, FILE_NAME’s originating system and preprocessor version and FILE_DESCRIPTION, which cadmpeg checks but does not keep, are read from the file’s HEADER section (in its first 256 KiB) by SolidCraft’s STEP parser; for an IGES file, the global section’s native system ID, which cadmpeg checks but leaves out of its model, is read from the global section’s cards cadmpeg keeps in its native iges namespace. The file’s assembly structure comes in as with SolidCraft’s reader: one component a product, nested as the file nests them, each placed in its parent, and a part the file places more than once comes in once at each placement. A component placement that mirrors or scales is left out with the reason, as one of a FreeCAD or Rhino body is. The same applies to a FreeCAD or Rhino file whose parts cadmpeg reads as placed occurrences, read with the switch on. Colours come in as with SolidCraft’s reader too: each body’s colour and its name in the file, its opacity, and the faces with colours of their own (cadmpeg reads a transparency in a SURFACE_STYLE_RENDERING_WITH_PROPERTIES, as the CAx-IF recommended practice writes it). A FreeCAD or Rhino file’s colours are not brought over yet. A solid that cannot be closed comes in as an open surface of the faces that read, without the faces its refusal names (each named in a warning), as with SolidCraft’s reader. Each face a refusal names costs one more read, up to eight: a solid whose refusals still name a face after the eighth, or name every face it has, is left out with its first refusal, as is one whose refusal names no face. A cavity whose outer shell has every face left out stays a cavity. A part the file gives as triangles alone (an AP242 tessellated shape) comes in as a mesh body, as an STL or 3MF import’s does; cadmpeg 0.6.12 does not say which product holds such a part, so in an assembly it comes in where the file defines it, with a warning, rather than where the assembly places it. Where the file states its parts’ volume, surface area or centre (the CAx-IF geometric validation properties), the imported bodies are measured and compared with them: a part whose bodies differ by more than the file’s stated error and 0.1% (a centre: 0.1% of the part’s size) is named in a warning with both figures, so a face left out or a part placed wrong shows even where the import looks whole. A centre is compared in the part’s own coordinates, as the file states it. The default, reader: "solidcraft", is the reader above and keeps the STEP text.

OpenUSD’s exact B-rep

An OpenUSD file opened or inserted with geometry: "exact" (doc.open, file.insert_mesh; meshes are the default) goes through the same records: cadmpeg’s usd codec decodes the stage, each BrepArray B-rep is read into B-rep records by solidcore-cadir, and a mesh with no B-rep becomes a mesh record, as a STEP file’s tessellated part does. cadmpeg makes a BrepArray’s fallback meshes tessellations of the B-rep body they show, and a tessellation of a body that has faces is not imported again, unless its B-rep cannot be read: that body then comes in as its fallback mesh, with a warning. cadmpeg 0.6.12 gives a NurbsPatch face no boundary (its trim curves are not read), and solidcore-cadir refuses a face with no boundary, so patches are left out with a warning. It also writes a cylinder’s side as a rational NURBS whose U runs a hair past a full turn, whose seam the records do not close yet, so SolidCraft’s own exported cylinders come back as their fallback meshes. The stage’s prims are the occurrences the assembly walk places; materials bound to a body or to its mesh give its colour, converted from USD’s linear colour to sRGB. The stage’s upAxis (Y when it says nothing) stands the import’s component up, as on the mesh route, and up overrides it.