MCPcopy Create free account
hub / github.com/CadQuery/cadquery / test_nested_subassembly_step_import

Function test_nested_subassembly_step_import

tests/test_assembly.py:1272–1299  ·  view source on GitHub ↗

Tests if the STEP import works correctly with nested subassemblies.

(tmpdir)

Source from the content-addressed store, hash-verified

1270
1271
1272def test_nested_subassembly_step_import(tmpdir):
1273 """
1274 Tests if the STEP import works correctly with nested subassemblies.
1275 """
1276
1277 # Create a simple assembly
1278 assy = cq.Assembly()
1279 assy.add(cq.Workplane().box(10, 10, 10), name="box_1")
1280
1281 # Create a simple subassembly
1282 subassy = cq.Assembly()
1283 subassy.add(cq.Workplane().box(5, 5, 5), name="box_2", loc=cq.Location(10, 10, 10))
1284
1285 # Nest the subassembly
1286 assy.add(subassy)
1287
1288 # Export and then re-import the nested assembly STEP
1289 with chdir(tmpdir):
1290 assy.export("nested_assembly_step.step")
1291 imported_assy = cq.Assembly.importStep("nested_assembly_step.step")
1292
1293 # Check the locations
1294 assert imported_assy.children[0].loc.toTuple()[0] == (0.0, 0.0, 0.0)
1295 assert imported_assy.children[1].objects["box_2"].loc.toTuple()[0] == (
1296 10.0,
1297 10.0,
1298 10.0,
1299 )
1300
1301
1302@pytest.mark.parametrize("kind", ["step", "xml", "xbf"])

Callers

nothing calls this directly

Calls 5

addMethod · 0.95
exportMethod · 0.95
boxMethod · 0.80
importStepMethod · 0.80
toTupleMethod · 0.45

Tested by

no test coverage detected