Last active
March 12, 2023 14:57
-
-
Save medicationforall/a86c159d184fac0db0ef6b6b60d60f93 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| # Making an obelisk in cadquery and cq-editor | |
| def pillar( | |
| points=[(0,0),(0,12.5),(2,12.5) ,(4,4), (4,0)], | |
| extrude=10, | |
| faces=4, | |
| intersect=True | |
| ): | |
| log("test_pillar") | |
| poly = ( | |
| cq.Workplane("XY") | |
| .polyline(points).close() | |
| .extrude(extrude) | |
| .translate((0,0,-1*(extrude/2))) | |
| ) | |
| mirror = ( | |
| cq.Workplane("XY") | |
| .union(poly) | |
| .union(poly.rotate((1,0,0),(0,0,0),180)) | |
| ) | |
| rotate_degrees = math.floor(360 / faces) | |
| rotations = int(faces/2)#? | |
| log(range(rotations)) | |
| scene = ( | |
| cq.Workplane("XY") | |
| .union(mirror) | |
| ) | |
| for i in range(rotations): | |
| if i == 0: | |
| scene = scene.union(mirror) | |
| else: | |
| if intersect: | |
| scene = scene.intersect(mirror.rotate((1,0,0),(0,0,0),rotate_degrees*i)) | |
| else: | |
| scene = scene.union(mirror.rotate((1,0,0),(0,0,0),rotate_degrees*i)) | |
| log('index is'+str(i)) | |
| return scene.rotate((0,1,0),(0,0,0),90) | |
| def obelisk( | |
| base_width=30, | |
| base_height=3, | |
| inset_width=15, | |
| inset_height=5, | |
| mid_width=30, | |
| mid_height=15, | |
| top_width=15, | |
| top_height=70, | |
| height=102, | |
| faces=4, | |
| intersect=True | |
| ): | |
| in_height = base_height + inset_height | |
| mid_height = in_height + mid_height | |
| t_height = mid_height + top_height | |
| points=[ | |
| (0,0), | |
| (0,base_width/2), | |
| (base_height, base_width/2), | |
| (in_height,inset_width/2), | |
| (mid_height, mid_width/2), | |
| (t_height, top_width/2), | |
| (height,0) | |
| ] | |
| extrude = base_width | |
| extrude = inset_width if inset_width > extrude else extrude | |
| extrude = mid_width if mid_width > extrude else extrude | |
| extrude = top_width if top_width > extrude else extrude | |
| return ( | |
| pillar(points, extrude, faces, intersect) | |
| .translate((0,0,-1*(height/2))) | |
| ) | |
| fantasy = obelisk( | |
| height=105 | |
| ) | |
| elven = obelisk( | |
| height=105, | |
| faces=6, | |
| intersect=True | |
| ) | |
| fantasy_elven = ( | |
| fantasy | |
| .union(elven) | |
| .union(elven.rotate((0,0,1),(0,0,0),90)) | |
| ) | |
| egypt = obelisk( | |
| base_width=30, | |
| base_height=5, | |
| inset_width=25, | |
| mid_width=25, | |
| mid_height=5, | |
| height=105 | |
| ) | |
| dwarven = obelisk( | |
| base_width=30, | |
| base_height=5, | |
| inset_width=25, | |
| mid_width=25, | |
| mid_height=5, | |
| height=105, | |
| faces=6, | |
| intersect=True | |
| ) | |
| egypt_dwarven = ( | |
| egypt | |
| .union(dwarven) | |
| .union(dwarven.rotate((0,0,1),(0,0,0),90)) | |
| ) | |
| crystal = obelisk( | |
| base_width=30, | |
| base_height=5, | |
| inset_width=10, | |
| mid_width=15, | |
| mid_height=5, | |
| top_width=40, | |
| height=105, | |
| faces=6, | |
| intersect=True | |
| ) | |
| evile = obelisk( | |
| base_width=40, | |
| base_height=3, | |
| inset_width=50, | |
| mid_width=5, | |
| mid_height=15, | |
| top_width=60, | |
| top_height=40, | |
| height=105, | |
| faces=8, | |
| intersect=False | |
| ) | |
| show_object(fantasy) | |
| show_object(elven.translate((-40,0,0))) | |
| show_object(fantasy_elven.translate((-80,0,0))) | |
| show_object(egypt.translate((0,40,0))) | |
| show_object(dwarven.translate((-40,40,0))) | |
| show_object(egypt_dwarven.translate((-80,40,0))) | |
| show_object(crystal.translate((0,80,0))) | |
| show_object(evile.translate((0,145,0))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment