cadjs polygons and polyarcs

19
CADjs Polygons and Polyarcs

Upload: percival-ray

Post on 18-Jan-2018

214 views

Category:

Documents


0 download

DESCRIPTION

Review Question Base: (50,50,2) Cylinder: r =5, h = 30 Hole: r = 2 Use one for-loop! Step 1 Step 2 Step 3 Step 4

TRANSCRIPT

Page 1: CADjs Polygons and Polyarcs

CADjs

Polygons and Polyarcs

Page 2: CADjs Polygons and Polyarcs

Review Question

Base: (50,50,2)Cylinder: r =5, h = 30Hole: r = 2

Use one for-loop!

Step 1 Step 2 Step 3 Step 4

Page 3: CADjs Polygons and Polyarcs

Review Question - Solution

base = cube(50,50,2);cyl1 = cylinder(5,30).rotateX(90).translateZ(15);cyl2 = cylinder(2,40).rotateX(90).translateZ(20);tube = cyl1.difference(cyl2).translate(20,20,0);

for (i = 0; i < 4;i++) { tube.rotateZ(90*i); base = base.union(tube);}base.display();

Page 4: CADjs Polygons and Polyarcs

Wedge

How to create?

Subtract one cube from another!

Page 5: CADjs Polygons and Polyarcs

Wedge

s=polygon([ [0,0],[1,0],[0,1] ]);s.display();

g = extrudeShape(s,0.25);//thicknessg.display();

(0,0)(1,0)

(1,0)

Page 6: CADjs Polygons and Polyarcs

Star

s = polygon([[0,50],[10,10],[50,10],[15,-10],[30,-50],[0,-20],[-30,-50],[-15,-10],[-50,10],[-10,10]]);s.display();

(0,50)

(10,10)(50,10)

Page 7: CADjs Polygons and Polyarcs

Star

s = polygon([[0,50],[10,10],[50,10],[15,-10],[30,-50],[0,-20],[-30,-50],[-15,-10],[-50,10],[-10,10]]);s.display();

g = extrudeShape(s,10);g.display();

Page 8: CADjs Polygons and Polyarcs

Hollow Wedge

s=polygon([ [0,0],[1,0],[0,1] ]);h = polygon([ [0.1,0.1],[0.8,0.1], [0.1,0.8]]);s.holes.push(h);s.display();

g = extrudeShape(s,0.2);g.display();

Page 9: CADjs Polygons and Polyarcs

Star with Hole

Page 10: CADjs Polygons and Polyarcs

Star with Hole

s = polygon([[0,50],[10,10],[50,10],[15,-10],[30,-50],[0,-20],[-30,-50],[-15,-10],[-50,10],[-10,10]]);

star = extrudeShape(s,10);hole = cylinder(5,30).rotateX(90);

star = star.difference(hole);star.display();

Page 11: CADjs Polygons and Polyarcs

Try …

100

20

10

R = 5

Page 12: CADjs Polygons and Polyarcs

Engineering Drawings

Page 13: CADjs Polygons and Polyarcs

More Examples

Method 1:Block + Cylinder

Method 2:Sketch and Extrude

Page 14: CADjs Polygons and Polyarcs

2D Shape with Arcs

s = start2DGeom(0,0);s.addLine(1,0);s.addArc(1,1,1,0.5,false); //xEnd,yEnd,xCenter,yCenter,Clockwises.addLine(0,1);s.display();//display 2D shape

(0,0) (1,0)

(1,1)(0,1)

(1,0.5) Anti-clockwise

Page 15: CADjs Polygons and Polyarcs

2D Shape with Arcs

s = start2DGeom(0,0);s.addLine(1,0).addLine(1,0.4).addLine(0.5,0.4);s.addArc(0.4,0.5,0.5,0.5,true); //xEnd,yEnd,xCenter,yCenter,Clockwises.addLine(0.4,1).addLine(0,1).addLine(0,0);s.display();//display 2D shape

(0,0)

(1,0)

(1,0.4)

(0.5,0.4)

(0.4,0.5)(0.5,0.5)

Clockwise

Page 16: CADjs Polygons and Polyarcs

Example

Page 17: CADjs Polygons and Polyarcs

Method 1

g= cube(60,20,38).translateZ(21);

g1 = cube(30,60,38).translateZ(49);

g2 = cylinder(30,20,100);

g3 = cylinder(15,50,39);

g = g.difference(g1).union(g2).difference(g3);

g.display();

Page 18: CADjs Polygons and Polyarcs

Method 2

arc = [38,60,38,30,false];s=polyarc([[0,0],[38,0], arc,[0,60],[0,45],[10,45],[10,15],[0,15] ] );g = extrudeShape(s,20);cyl = cylinder(15,25).rotateX(90).translate(38,30,10);g = g.difference(cyl);g.display();

Page 19: CADjs Polygons and Polyarcs

Method 3

arc = [38,60,38,30,false];s = polyarc([[0,0],[38,0], arc,[0,60],[0,45],[10,45],[10,15],[0,15] ] );c = circle(38,30,15);s.holes.push(c);g = extrudeShape(s,20);g.display();