Builds an assembly with the needed subshapes to test the export and import of STEP files.
()
| 369 | |
| 370 | @pytest.fixture |
| 371 | def subshape_assy(): |
| 372 | """ |
| 373 | Builds an assembly with the needed subshapes to test the export and import of STEP files. |
| 374 | """ |
| 375 | |
| 376 | # Create a simple assembly |
| 377 | assy = cq.Assembly(name="top_level") |
| 378 | cube_1 = cq.Workplane().box(10.0, 10.0, 10.0) |
| 379 | assy.add(cube_1, name="cube_1", color=cq.Color("green")) |
| 380 | |
| 381 | # Add subshape name, color and layer |
| 382 | assy["cube_1"].addSubshape( |
| 383 | cube_1.faces(">Z").val(), |
| 384 | name="cube_1_top_face", |
| 385 | color=cq.Color("red"), |
| 386 | layer="cube_1_top_face_layer", |
| 387 | ) |
| 388 | |
| 389 | # Add a cylinder to the assembly |
| 390 | cyl_1 = cq.Workplane().cylinder(10.0, 2.5) |
| 391 | assy.add( |
| 392 | cyl_1, name="cyl_1", color=cq.Color("blue"), loc=cq.Location((0.0, 0.0, -10.0)) |
| 393 | ) |
| 394 | |
| 395 | # Add a subshape face for the cylinder |
| 396 | assy["cyl_1"].addSubshape( |
| 397 | cyl_1.faces("<Z").val(), |
| 398 | name="cylinder_bottom_face", |
| 399 | color=cq.Color("green"), |
| 400 | layer="cylinder_bottom_face_layer", |
| 401 | ) |
| 402 | |
| 403 | # Add a subshape wire for the cylinder |
| 404 | assy["cyl_1"].addSubshape( |
| 405 | cyl_1.wires("<Z").val(), |
| 406 | name="cylinder_bottom_wire", |
| 407 | color=cq.Color("blue"), |
| 408 | layer="cylinder_bottom_wire_layer", |
| 409 | ) |
| 410 | |
| 411 | # Add two subshapes with the same name |
| 412 | assy["cyl_1"].addSubshape(cyl_1.faces(">Z").val(), name="2_faces") |
| 413 | assy["cyl_1"].addSubshape(cyl_1.faces("<Z").val(), name="2_faces") |
| 414 | |
| 415 | return assy |
| 416 | |
| 417 | |
| 418 | @pytest.fixture |