Last active
July 23, 2023 09:21
-
-
Save medicationforall/a44ec4a10e4e993f46809f3904d6d8c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cadquery as cq | |
import math | |
def mesh_pattern( | |
radius=2, | |
height = 10, | |
m_radius=.5, | |
m_padding = .5 | |
): | |
m_cylinder = ( | |
cq.Workplane("XY") | |
.cylinder(radius*2, m_radius) | |
.rotate((0,1,0),(0,0,0),90) | |
) | |
mesh = ( | |
cq.Workplane("XY") | |
) | |
circumference = math.floor(2 * math.pi * radius) | |
mesh_repeat = math.floor(math.floor(circumference/(m_radius*2+m_padding ))) | |
if mesh_repeat % 2 == 1: | |
mesh_repeat -= 1 | |
log('it\'s odd') | |
rotation = 360 / (mesh_repeat) | |
log(f'circumferece {circumference}, repeat {mesh_repeat}, rotation {rotation}') | |
for i in range(mesh_repeat): | |
mesh = ( | |
mesh | |
.union( | |
m_cylinder | |
.rotate((0,0,1),(0,0,0), rotation*i) | |
) | |
) | |
return mesh | |
def exhaust_mesh( | |
radius=2, | |
height = 10, | |
m_radius=.5, | |
m_padding = 0, | |
col_rotate = 0 | |
): | |
cylinder = cq.Workplane("XY").cylinder(height, radius) | |
r_pattern = mesh_pattern( | |
radius = radius, | |
height = height, | |
m_radius=m_radius, | |
m_padding = m_padding | |
) | |
c_pattern = ( | |
cq.Workplane("XY") | |
) | |
c_repeat = math.floor(height / (m_radius*2+m_padding*2)) | |
#log(f'c_repeat {c_repeat}') | |
for i in range(c_repeat): | |
c_pattern = c_pattern.union( | |
r_pattern | |
.translate((0,0,i*(m_radius*2+m_padding*2))) | |
.rotate((0,0,1),(0,0,0), col_rotate*i) | |
) | |
#return c_pattern | |
return ( | |
cylinder | |
.cut( | |
c_pattern | |
.translate((0,0,-1*(height/2)+m_radius+m_padding*2)) | |
) | |
) | |
test = exhaust_mesh( | |
radius = 2, | |
height = 10, | |
m_radius = 0.5, | |
m_padding=.25, | |
col_rotate = 23 | |
) | |
show_object(test) |
Author
medicationforall
commented
Jul 23, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment