Test if a STEP/XBF/XML file containing subshape information can be imported correctly.
(tmpdir, subshape_assy, kind)
| 1069 | |
| 1070 | @pytest.mark.parametrize("kind", ["step", "xml", "xbf"]) |
| 1071 | def test_assembly_subshape_import(tmpdir, subshape_assy, kind): |
| 1072 | """ |
| 1073 | Test if a STEP/XBF/XML file containing subshape information can be imported correctly. |
| 1074 | """ |
| 1075 | |
| 1076 | assy_step_path = f"subshape_assy.{kind}" |
| 1077 | |
| 1078 | with chdir(tmpdir): |
| 1079 | # Export the assembly |
| 1080 | subshape_assy.export(assy_step_path) |
| 1081 | |
| 1082 | # Import the file back in |
| 1083 | imported_assy = cq.Assembly.load(assy_step_path) |
| 1084 | |
| 1085 | assert imported_assy.name == "top_level" |
| 1086 | |
| 1087 | # Check the advanced face name |
| 1088 | assert len(imported_assy.children[0]._subshape_names) == 1 |
| 1089 | assert ( |
| 1090 | list(imported_assy.children[0]._subshape_names.values())[0] == "cube_1_top_face" |
| 1091 | ) |
| 1092 | |
| 1093 | # Check the color |
| 1094 | color = list(imported_assy.children[0]._subshape_colors.values())[0] |
| 1095 | assert Quantity_NameOfColor.Quantity_NOC_RED == color.wrapped.GetRGB().Name() |
| 1096 | |
| 1097 | # Check the layer info |
| 1098 | layer_name = list(imported_assy["cube_1"]._subshape_layers.values())[0] |
| 1099 | assert layer_name == "cube_1_top_face_layer" |
| 1100 | |
| 1101 | assert ( |
| 1102 | "cylinder_bottom_face_layer" in imported_assy["cyl_1"]._subshape_layers.values() |
| 1103 | ) |
| 1104 | assert ( |
| 1105 | "cylinder_bottom_wire_layer" in imported_assy["cyl_1"]._subshape_layers.values() |
| 1106 | ) |
| 1107 | |
| 1108 | |
| 1109 | @pytest.mark.parametrize("kind", ["step", "xml", "xbf"]) |