-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpara_grid.py
More file actions
37 lines (30 loc) · 905 Bytes
/
para_grid.py
File metadata and controls
37 lines (30 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import cadquery
import Part
x_length = 40.0
y_length = 40.0
z_length = 3.0
outer_gap = 5.0
inner_gap = 5.0
x_count = 7
y_count = 2
if (outer_gap*2)+((x_count-1)*inner_gap) >= x_length:
x_length = ((outer_gap*2)+((x_count-1)*inner_gap))+1
inner_gap = 1
if (outer_gap*2)+((y_count-1)*inner_gap) >= y_length:
y_length = ((outer_gap*2)+((y_count-1)*inner_gap))+1
inner_gap = 1
x_cell = x_length-(outer_gap*2)
x_cell = x_cell-((x_count-1)*inner_gap)
x_cell = x_cell/x_count
array_x = x_cell+inner_gap
y_cell = y_length-(outer_gap*2)
y_cell = y_cell-((y_count-1)*inner_gap)
y_cell = y_cell/y_count
array_y = y_cell+inner_gap
result = cadquery.Workplane('XY')
result = result.rect(x_length, y_length)
result = result.workplane()
result = result.rarray(array_x, array_y, x_count, y_count)
result = result.rect(x_cell, y_cell)
result = result.extrude(z_length)
Part.show(result.toFreecad())