Skip to content

Instantly share code, notes, and snippets.

@lf94
Created January 16, 2024 00:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lf94/31c78ed7a80173933a02e3bfb7426434 to your computer and use it in GitHub Desktop.
Save lf94/31c78ed7a80173933a02e3bfb7426434 to your computer and use it in GitHub Desktop.
Prompt: A flowerpot of 10 cm diameter
import cadquery as cq
# Parameters
diameter = 10.0 # Diameter of the flowerpot
height = 10.0 # Height of the flowerpot
thickness = 0.5 # Wall thickness of the flowerpot
bottom_thickness = 0.5 # Bottom thickness of the flowerpot
# Create the outer shell of the flowerpot
outer_shell = cq.Workplane("XY").circle(diameter / 2).extrude(height)
# Create the inner cavity by offsetting the outer shell inwards
inner_shell = (
outer_shell.faces("<Z")
.workplane()
.circle((diameter / 2) - thickness)
.extrude(height - bottom_thickness)
)
# Subtract the inner cavity from the outer shell to create the hollow flowerpot
flowerpot = outer_shell.cut(inner_shell)
# Export the result
cq.exporters.export(flowerpot, "/tmp/70ba5db4-27b0-4812-955c-114cf5c0fdc4.step")
import cadquery as cq
# Parameters
diameter = 10.0 # Diameter of the flowerpot
height = 10.0 # Height of the flowerpot
thickness = 0.5 # Wall thickness of the flowerpot
bottom_thickness = 0.5 # Bottom thickness of the flowerpot
# Create the outer shell of the flowerpot
outer_shell = cq.Workplane("XY").circle(diameter / 2).extrude(height)
# Create the inner cavity by offsetting the outer shell inwards
inner_shell = (
outer_shell.faces("<Z")
.workplane(-bottom_thickness)
.circle((diameter / 2) - thickness)
.extrude(-(height - bottom_thickness), False)
)
# Subtract the inner cavity from the outer shell to create the hollow flowerpot
flowerpot = outer_shell.cut(inner_shell)
# Export the result
cq.exporters.export(flowerpot, "/tmp/70ba5db4-27b0-4812-955c-114cf5c0fdc4.step")
import cadquery as cq
# Parameters
diameter = 10.0 # Diameter of the flowerpot
height = 10.0 # Height of the flowerpot
thickness = 0.5 # Wall thickness of the flowerpot
bottom_thickness = 0.5 # Bottom thickness of the flowerpot
# Create the outer shell of the flowerpot
outer_shell = cq.Workplane("XY").circle(diameter / 2).extrude(height)
# Create the inner cavity by offsetting the outer shell inwards
inner_shell = (
outer_shell.faces("<Z")
.workplane(bottom_thickness, True)
.circle((diameter / 2) - thickness)
.extrude(height - bottom_thickness, False)
)
# Subtract the inner cavity from the outer shell to create the hollow flowerpot
flowerpot = outer_shell.cut(inner_shell)
# Export the result
cq.exporters.export(flowerpot, "/tmp/70ba5db4-27b0-4812-955c-114cf5c0fdc4.step")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment