# Pumpkin Patch - 3d Printable

46

1

2

My goal is to create a 3d printable pumpkin patch! I'm using the mathematical 3D design tool OpenScad. This instructable will walk you through the steps from forming a pumpkin, varying its shape, creating a patch, creating a leaf bed, and putting it all together!

My design file is attached, pumpkin_patch.scad.txt.

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## Step 1: Model of a Pumpkin

First I give credit to KySyth for their "Pumpkin OpenScad" model on thingiverse. I started with that and ran forward!

A pumpkin consists of "ribs" of varying quantity, around an approximate sphere, plus a stem on top. This model will vary the number of ribs, vary the total size, vary the slenderness vs short and fatness, and make the pumpkin mis-shapen (leaning to the side).

See my function Pumpkin2(), relying on module Slice().
Slice() creates one rib, and Pumpkin2() rotates a sequence of Slice()s around a circle, but placing them so close together they overlap!
The first image shows one slice standing alone. Think of it as a squashed sphere! The second image is a sequence of them so tight together they form the pumpkin shape!

In Pumpkin2() see the loop a=1:segs, and for each segment places a Slice at 360 degrees/a.

To create the misshapenness, a height variation called tiltAmt is applied, so the Slice varies in height according to its position around the circle. This is calculated with sin(angleLocation/2)*tiltAmt, going from min height to max and back to min in one 360 degree sweep. See image 4.

Finally the fat parameter causes the slices to be slightly further apart, such that the slices joined dip down in the center, see image 3.

## Step 2: Create a Set of Various Shaped Pumpkins

See module pumpkin_set1(), which creates 3 pumpkins of various sizes next to each other. An overall width of the resulting set is used to govern the size of each pumpkin.

Then pumpkin_pile_base() joins 2 such sets, using rotation so they don't look too similar!

By commenting out the final function call in the .scad file, pumpkin_pile_base_mold();, and uncomment the call the pumpkin_pile_base(), you can see just this set.

## Step 3: Creating a Leaf

To create a leaf, I import an image of a leaf, and turn it into an object in Openscad!
See module pumpkin_leaf(), which includes file pumpkin_leaf-50.png image file.
The openscad object is image 2.

For variation, I extend the leaf model by allowing it to vary its angle, and projecting a "shadow" below it, to fill out space. This will make a solid bed!
See module pumpkin_leaf_angle(). This module emits an angled leaf, followed by a projection() of the same leaf below it, and joined together. See the 3rd image in this step.

The first file in this step is the leaf image file.

## Step 4: Creating a Leaf Bed

For this I use a random number generator to position the same leaf at various angles, in an X-Y pattern. The first image shows the leaves so laid out, but made 1/4 smaller so you can see their random positioning.
This is done in module pumpkin_leaf_bed_rand(). Note that this function, with a shadow below every leaf, is very expensive and takes many minutes to run!

Pumpkin_leaf_bed_rand() calculates a number of x and y leaves. Then loops through them and positions each leaf using the random number array to jitter the positioning.

Now just relying on the random number generator results in leaves which have gaps between them. I don't want any holes in my model! To avoid holes, I add a table, leaf_adj[], which is a leaf number plus an x and y adjustment in position. Repeatedly I generate the bed, entering adjustment values, until each hole is closed!
Most leaves don't have to be adjusted, so only index values of ones I wanted to nudge a bit are present. To do these table entries, and avoid the long runtimes of the shadow calculations, I temporarily comment out some code in pumpkin_leaf_angle() to avoid generating the expensive projection!

The second image shows the final leaf bed. Notice the shadow projection below each leaf creates a solid bed. Plus the random angle of each leaf creates a nice variance!

## Step 5: Putting It All Together

Our final module, pumpkin_pile_base_mold() combines the leaf bed with the pumpkin set. Some fine positioning is done via translate(). Finally the bed is trimmed at z=0, with difference() and a cube(), to make a nice shape standing on the XY plane, with base at z=0.

And printed in resin, as shown in the image!

25 1.9K
2 298
102 10K

## 2 Discussions

This is a really neat way to use randomization to make something cool! Thanks for posting it!