Skip to content
brep-conformancegithub

sew

Exchange · api.md § sew · all operations

sew(text: string, tolerance: Length) -> Solid

Sews the faces of a STEP file into one closed solid. text is the contents of a STEP file that holds loose faces and no solid.

In a solid, two faces that meet share one edge, and that sharing is what makes the solid's boundary closed. A file of loose faces has lost that sharing. Each face is written as a surface of its own, with its own copy of every edge and corner, so nothing in the file says which faces are neighbours. Files like this come from tools that export surfaces, or that drop a solid's connections on the way out. The faces in such files may not quite meet, and some faces may be written inside out.

Sewing joins the faces wherever their edges lie within tolerance of each other, and turns any face written inside out to face outward. tolerance must be positive, and the faces must close into a solid once joined. A prism whose faces are written loose and shifted apart by less than the tolerance sews back into the prism, to within the shifts.

Example. The file holds the six faces of a 10 × 20 × 30 mm box, each written as its own surface with its own edges and corners. Three are shifted off the box by less than 0.0001 mm, and one is written inside out. Sewn, they close into the box: volume of the result gives 6000.04 mm³, the box's 6000 to within the shifts.

> {"cmd": "sew", "text": "ISO-10303-21;\nHEADER;\nFILE_DESCRIPTION((''),'2;1');\n
   FILE_NAME('case','',(''),(''),'','','');\n
   FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214… (15,069 characters)", "tolerance": 0.002}
< {"ok": 1}

A STEP file travels as a string holding the file's contents: all of its text, from ISO-10303-21; to END-ISO-10303-21;, in the clear-text encoding of ISO 10303-21. The string is never a path or a file name, because the kernel and the suite need not share a disk. The adapter hands the kernel that text as UTF-8 bytes. The files the suite writes use only the standard's basic alphabet, which is plain ASCII.

FunctionFieldsReturns
write_stepsstring
sewtext, toleranceSolid
read_steptextSolid