MCPcopy
hub / github.com/CadQuery/cadquery / test_meta_step_export

Function test_meta_step_export

tests/test_assembly.py:725–835  ·  view source on GitHub ↗

Tests that an assembly can be exported to a STEP file with faces tagged with names and colors, and layers added.

(tmpdir)

Source from the content-addressed store, hash-verified

723
724
725def test_meta_step_export(tmpdir):
726 """
727 Tests that an assembly can be exported to a STEP file with faces tagged with names and colors,
728 and layers added.
729 """
730
731 # Most nested level of the assembly
732 subsubassy = cq.Assembly(name="third-level")
733 cone_1 = cq.Workplane(cone(5.0, 10.0, 5.0))
734 cone_2 = cq.Workplane(cone(2.5, 5.0, 2.5))
735 subsubassy.add(
736 cone_1,
737 name="cone_1",
738 color=cq.Color(1.0, 1.0, 1.0),
739 loc=cq.Location(-15.0, 10.0, 0.0),
740 )
741 subsubassy.add(
742 cone_2,
743 name="cone_2",
744 color=cq.Color(0.0, 0.0, 0.0),
745 loc=cq.Location((15.0, 10.0, -5.0)),
746 )
747
748 # First layer of nested assembly
749 subassy = cq.Assembly(name="second-level")
750 cylinder_1 = cq.Workplane().cylinder(radius=5.0, height=10.0)
751 cylinder_2 = cq.Workplane().cylinder(radius=2.5, height=5.0)
752 subassy.add(
753 cylinder_1,
754 name="cylinder_1",
755 color=cq.Color(1.0, 1.0, 0.0),
756 loc=cq.Location(-15.0, 0.0, 0.0),
757 )
758 subassy.add(
759 cylinder_2,
760 name="cylinder_2",
761 color=cq.Color(0.0, 1.0, 1.0),
762 loc=cq.Location((15.0, -10.0, -5.0)),
763 )
764 subassy.add(subsubassy)
765
766 # Top level of the assembly
767 assy = cq.Assembly(name="top-level")
768 cube_1 = cq.Workplane().box(10.0, 10.0, 10.0)
769 assy.add(cube_1, name="cube_1", color=cq.Color(0.5, 0.0, 0.5))
770 cube_2 = cq.Workplane().box(5.0, 5.0, 5.0)
771 assy.add(
772 cube_2,
773 name="cube_2",
774 color=cq.Color(0.0, 0.5, 0.0),
775 loc=cq.Location(10.0, 10.0, 10.0),
776 )
777 assy.add(subassy)
778
779 # Tag faces to test from all levels of the assembly
780 assy.addSubshape(cube_1.faces(">Z").val(), name="cube_1_top_face")
781 assy.addSubshape(cube_1.faces(">Z").val(), color=cq.Color(1.0, 0.0, 0.0))
782 assy.addSubshape(cube_1.faces(">Z").val(), layer="cube_1_top_face")

Callers

nothing calls this directly

Calls 8

addMethod · 0.95
addSubshapeMethod · 0.95
facesMethod · 0.95
coneFunction · 0.90
exportStepMetaFunction · 0.90
cylinderMethod · 0.80
boxMethod · 0.80
valMethod · 0.45

Tested by

no test coverage detected