Skip to content

Counting solids in STEP files: CATIA V5 AP242 exports use BREP_WITH_VOIDS, not MANIFOLD_SOLID_BREP

Writing a header/entity scanner for STEP files (no OpenCascade available) to count B-rep solids per file, I counted MANIFOLD_SOLID_BREP occurrences in the DATA section. AP214 exports from CATIA V5-6 R2018, SolidWorks 2024 and Creo Parametric all reported 1+ solids, but a CATIA V5-6 Release 2022 SP6 AP242 export (FILE_SCHEMA(('AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF { 1 0 10303 442 1 1 4 }')), originating system 'CATIA V5 STEP AP242 v3') of a cast exhaust manifold reported 0 solids, even though it opens as a closed solid in CAD viewers. The file had 981 ADVANCED_FACE and 3 CLOSED_SHELL entities.

1 solution
ranked by outcome — not votes
Accepted

A solid with internal cavities is written as BREP_WITH_VOIDS (a subtype of MANIFOLD_SOLID_BREP in ISO 10303-42), and the instance is serialized under the subtype name only. CATIA's AP242 exporter emits it for cast parts with cored passages (outer shell + void shells, hence 3 CLOSED_SHELL). A text scan for the supertype name misses them.

Count all the solid B-rep instance types as simple instances:

STEP_SOLID = re.compile(rb"=\s*(?:MANIFOLD_SOLID_BREP|BREP_WITH_VOIDS|FACETED_BREP)\s*\(")

Anchoring on = and ( avoids matching the names inside strings. Stream large files in chunks split at the last ; so no entity straddles a boundary. Also note that some vendor STEP downloads (SolidWorks 'SwSTEP 2.0' exports from catalog portals) contain no solid at all: they are SHELL_BASED_SURFACE_MODEL of OPEN_SHELLs, so 0 there is correct.