3D Model for Piggy Bank

We were asked to build a 3D model for something that could fit into another object or that could hold something. So I decided on making a piggy bank which is always a great place to store money.

For modelling the piggy bank  I used OpenJSCAD and CraftML . Both of which are web based 3D modelling tools and which uses Javascript. It was easy to model and I did not face any challenges as I have been 3D modelling for some time.

I have used spheres and cylinders mainly to build this model. There are also other functions that I used to rotate, position the various components in place.

Following is the code for the piggy bank:

function main()
 return union(body(),head());

function body()
 var b=cylinder({r: 1.5, h:1.5 , round: true}).rotateX(90);
 var hole=cube({size:[0.1,1,2]}).translate([0,-0.5,0.5]);
 var l1=cylinder({r: 0.25, h: 0.7}).translate([0.6,0,-1.1]);
 var l2=cylinder({r: 0.25, h: 0.7}).translate([-0.6,0,-1.1]);
 var l3=cylinder({r: 0.25, h: 0.7}).translate([0.6,-1.6,-1.1]);
 var l4=cylinder({r: 0.25, h: 0.7}).translate([-0.6,-1.6,-1.1]);
 var tail=cylinder({start: [0,0,0], end: [0,0,0.5], r1:0.3, r2: 0.05, fn: 30}).rotateX(70);
 var tailTrans=tail.translate([0,-2.35,0.3]);
 var body1= union(b,l1,l2,l3,l4,tailTrans);
 return body1.subtract(hole);

function head()
 var h=sphere({r:0.8}).translate([0,1.2,0]);
 var hornL=cylinder({start: [0,0,0], end: [0,0,0.35], r1:0.25, r2: 0.05, fn: 30}).rotateY(50);
 var hornLTrans=hornL.translate([0.6,1.1,0.4]);
 var hornR=cylinder({start: [0,0,0], end: [0,0,0.35], r1:0.25, r2: 0.05, fn: 30}).rotateY(295);
 var hornRTrans=hornR.translate([-0.6,1.1,0.4]);
 var eyeR=sphere({r:0.1}).translate([-0.3,1.8,0.45]);
 var eyeL=sphere({r:0.1}).translate([0.3,1.8,0.45]);
 var nose=cylinder({r: 0.25, h: 0.2}).translate([0,1.8,0]);
 var noseRot=nose.rotateX(90).translate([0,2.12,-1.8]);
 var nholeR=sphere({r:0.1}).translate([-0.11,2.12,0]);
 var nholeL=sphere({r:0.1}).translate([0.11,2.12,0]);
 var head1=union(h,hornLTrans,hornRTrans,eyeR,eyeL,noseRot);
 var headFinal=difference(head1,nholeR,nholeL);
 return headFinal;

Here is a picture of how it looks:



Model in OpenJSCAD

Link to my Thingiverse where you can find the model:


Hope you like it. 🙂


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s