Skip to content

Commit c473478

Browse files
committed
In theory, this should pass lint check and tests, and upload renders as artifacts
1 parent 3a26509 commit c473478

File tree

8 files changed

+363
-60
lines changed

8 files changed

+363
-60
lines changed

.github/workflows/test.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,9 @@ jobs:
3737
uses: coactions/setup-xvfb@v1
3838
with:
3939
run: pytest
40+
41+
- name: Upload rendered images as artifacts for inspection
42+
uses: actions/upload-artifact@v3
43+
with:
44+
name: rendered-images
45+
path: renders/*.png

generate.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Currently the configuration is just a list of the networking components which ar
5050

5151
To generate run the following:
5252

53-
cadorchestrator generate '["NUC10i5FNH", "Raspberry_Pi_4B", "Raspberry_Pi_4B"]'
53+
cadorchestrator generate '{"device-ids": ["NUC10i5FNH", "Raspberry_Pi_4B", "Raspberry_Pi_4B"]}'
5454

5555
This should create the `build` directory. Inside this the `printed_components` directory should contain a number of `stl` files that can be 3D printed. It will also contain `step` files for each of these components.
5656

mechanical/assembly_renderer.py

+328-45
Large diffs are not rendered by default.

nimble_build_system/cad/fasteners.py

-7
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,6 @@ def direction_axis(self):
101101
"""
102102
return self._direction_axis
103103

104-
@name.setter
105-
def direction_axis(self, axis):
106-
"""
107-
Setter for the direction axis of the fastener.
108-
"""
109-
self._direction_axis = axis
110-
111104
@property
112105
def rotation(self):
113106
"""

nimble_build_system/cad/renderer.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1+
"""
2+
Helper module to render a CadQuery model to a PNG image file.
3+
"""
4+
15
#pylint: disable=too-few-public-methods
26
#pylint: disable=unused-import
37

48
import cadquery as cq
59
import cadquery_png_plugin.plugin # This activates the PNG plugin for CadQuery
610
from cq_annotate.callouts import add_assembly_lines
711

8-
def generate_render(model=None, image_format="png", file_path=None, render_options=None):
12+
def generate_render(model=None,
13+
image_format="png",
14+
file_path=None,
15+
render_options=None,
16+
selective_list=None):
917
"""
1018
Generates a render of an assembly.
1119
@@ -24,7 +32,7 @@ def generate_render(model=None, image_format="png", file_path=None, render_optio
2432
if isinstance(model, cq.Assembly):
2533
# Handle assembly annotation
2634
if render_options["annotate"]:
27-
add_assembly_lines(model)
35+
add_assembly_lines(model, selective_list=selective_list)
2836

2937
# Handle the varioius image formats separately
3038
if image_format == "png":

nimble_build_system/cad/shelf.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,10 @@ def generate_shelf_model(self) -> cadscript.Body:
10391039
screw_y = 7 # distance from bottom plane
10401040
self.width_category = "standard"
10411041
builder = ShelfBuilder(
1042-
self.height_in_u, width=self.width_category, depth="standard", front_type="w-pattern"
1042+
self.height_in_u,
1043+
width=self.width_category,
1044+
depth="standard",
1045+
front_type="w-pattern"
10431046
)
10441047
builder.make_tray(sides="slots", back="open")
10451048
mount_sketch = cadscript.make_sketch()

nimble_build_system/orchestration/device.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ def __init__(self, device_id, rack_params, dummy=False, dummy_data:dict|None=Non
8484
if self.height:
8585
self.height_in_u = ceil((self.height+4)/rack_params.mounting_hole_spacing)
8686
else:
87-
raise RuntimeError("Not enough information provided to generate shelf height") from exc
87+
raise RuntimeError("Not enough information provided to generate shelf height")\
88+
from exc
8889

8990
self.shelf_id = device_dict['ShelfId']
9091
self.shelf_type = device_dict['Shelf']

tests/test_rendering.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ def test_png_rendering():
2828

2929
# Check all of the shelf assemblies
3030
for cur_shelf in config._shelves:
31-
32-
# Set up a temporary path to export the image to that we can upload artifacts from
33-
temp_dir = "./renders"
31+
# Create the temporary directory if it does not exist
32+
temp_dir = os.path.join(Path(os.curdir).resolve().parent, "renders")
33+
if not os.path.exists(temp_dir):
34+
os.makedirs(temp_dir)
3435

3536
# Do a sample render of the shelf assembly
3637
cur_shelf.generate_renders(temp_dir)
@@ -51,5 +52,13 @@ def test_final_assembly_png_rendering():
5152
os.chdir(folder)
5253
assembly = AssemblyRenderer(def_file.name)
5354

55+
# Create the temporary directory if it does not exist
56+
temp_dir = os.path.join(Path(os.curdir).resolve().parent, "renders")
57+
if not os.path.exists(temp_dir):
58+
os.makedirs(temp_dir)
59+
5460
# Generate the assembly process renders
5561
assembly.generate_assembly_process_renders()
62+
63+
assert os.path.isfile(os.path.join(temp_dir, "final_assembly_step_1_annotated.png"))
64+
assert os.path.isfile(os.path.join(temp_dir, "final_assembly_step_1_assembled.png"))

0 commit comments

Comments
 (0)