Gear
Previous Topic  Next Topic 

 

 

Gear

 

 

 

 

             // Create a profile 

            sdLwPolyline poly = fDrawCtrl1.Document.CreateLwPolyline();

            poly.AddVertex(new Point3D(-145, -5, 0));

            poly.AddVertex(new Point3D(-145, 5, 0));

            poly.AddVertex(new Point3D(-115, 10, 0));

            poly.AddVertex(new Point3D(-115, -10, 0));

 

            // Create an extruded solids

            sd3dSolid solid = fDrawCtrl1.Document.AddSolidExtruded(poly, 50);

 

            // Create multiple solids by rotating a base solid about the Z Axis.

            List<sd3dSolid> RevSolids = fDrawCtrl1.Document.AddMultipleRevolveSolid(solid, 20, 360, new Point3D(0, 0, 0), new Point3D(0, 0, 1));

 

            sdCircle cir0 = fDrawCtrl1.Document.CreateCircle(new Point3D(0, 0, 0), 95);

            sdCircle cir1 = fDrawCtrl1.Document.CreateCircle(new Point3D(0, 0, 0), 120);

 

            // Create small extruded solid

            sd3dSolid CirSolid1 = fDrawCtrl1.Document.AddSolidExtruded(cir0, 50);

            // Create big extrude solid.

            sd3dSolid CirSolid2 = fDrawCtrl1.Document.AddSolidExtruded(cir1, 50);

            // Create a cylinder with an opening at the center.

            sd3dSolid CirSolid3 = fDrawCtrl1.Document.AddSolidOpSubtract(CirSolid2, CirSolid1, falsefalse);

 

            // Add the base solid into the RevSolids list.

            RevSolids.Add(solid);

 

            // Union All the solids to create a gear shape.

            for (int i = 0; i < RevSolids.Count; i++)

            {

                CirSolid3 = fDrawCtrl1.Document.CreateSolidOpUnion(CirSolid3, RevSolids[i], falsefalse);

            }

 

            fDrawCtrl1.Document.AddObject(CirSolid3);

 

            sdCircle cir2 = fDrawCtrl1.Document.CreateCircle(new Point3D(0, 0, 0), 180);

            // Create a second cylinder that with an opening at the center of the solid.

            sd3dSolid CirSolid4 = fDrawCtrl1.Document.AddSolidExtruded(cir2, 50);

            CirSolid1 = fDrawCtrl1.Document.CreateSolidExtruded(cir0, 50);

            sd3dSolid cirSolid5 = fDrawCtrl1.Document.AddSolidOpSubtract(CirSolid4, CirSolid1, falsetrue);

 

            // Subtract gear with Cylinder to create an XOR of gear.

            sd3dSolid GearXor = fDrawCtrl1.Document.AddSolidOpSubtract(cirSolid5, CirSolid3, falsetrue);

            GearXor.Move(new Point3D(0, 400, 0));

 

            fDrawCtrl1.Document.ZoomAll();

            fDrawCtrl1.Refresh();