Example #1
0
        public override void Run(string path)
        {
            Model model = new Model();

            // Create a definition of a square shape.

            CompDef square = new CompDef(
                "Flat",
                "A Square");

            // Add a square polygon to the definition.

            Point3[] squarePoints =
            {
                new Point3(-1, 0, -1),
                new Point3(1,  0, -1),
                new Point3(1,  0,  1),
                new Point3(-1, 0, 1)
            };

            square.Add(squarePoints);

            // Add the square definition to the model.

            model.Add(square);

            // Create an instance of a definition that does not
            // yet exist in the model.

            CompInst pointyInstance = new CompInst
            {
                // Refer here to a definition we'll create later.

                ComponentName = "Pointy",
                InstanceName  = "Tri the Angle"
            };

            // Move the instance away from the origin a bit.

            pointyInstance.Transform.Translation.Y = 1;
            pointyInstance.Transform.Rotation.Z    = -20;

            // Add the instance to the square's definition.

            square.Add(pointyInstance);

            // Instantiate the square definition.

            CompInst squareInstance = new CompInst
            {
                ComponentName = "Flat",
                InstanceName  = "Quad the First"
            };

            // Add the instance to the model.

            model.Add(squareInstance);

            // Now create the "Pointy" definition (a triangle).

            CompDef pointy = new CompDef(
                "Pointy",
                "A Triangle");

            // Define a triangular shape.

            Point3[] pointyPoints =
            {
                new Point3(-1, 0, -1),
                new Point3(1,  0, -1),
                new Point3(0,  0, 1)
            };

            // Add the shape to the defintion.

            pointy.Add(pointyPoints);

            // Add the definition to the model.

            model.Add(pointy);

            model.WriteSketchUpFile(path + @"\ForwardComponent.skp");
        }
Example #2
0
        public override void Run(string path)
        {
            Model model = new Model();

            // Create a definition in a triangle shape.

            CompDef pointy = new CompDef("Pointy", "A Triangle");

            // Add the definition to the model.

            model.Add(pointy);

            // Lay out the points of the triangle.

            Point3[] pointyPoints =
            {
                new Point3(-1, 0, -1),
                new Point3(1,  0, -1),
                new Point3(0,  0, 3)
            };

            // Use them to add a face to the definition.

            pointy.Add(pointyPoints);

            // Create a definition in a square shape.

            CompDef flat = new CompDef(
                "Flat",
                "A Square");

            // Add the definition to the model.

            model.Add(flat);

            // Lay out the points of a square.

            Point3[] flatPoints =
            {
                new Point3(-1, 0, -1),
                new Point3(1,  0, -1),
                new Point3(1,  0,  1),
                new Point3(-1, 0, 1)
            };

            // Use them to add a face to the definition.

            flat.Add(flatPoints);

            // Create an instance of the triangle.

            CompInst ci2 = new CompInst
            {
                ComponentName = "Pointy",
                InstanceName  = "Tri the Angle"
            };

            // Move it away from the square.

            ci2.Transform.Translation.Y = 10;
            ci2.Transform.Rotation.X    = 45;
            ci2.Transform.Rotation.Y    = 90;
            ci2.Transform.Rotation.Z    = -40;

            // Add the instance of the triangle to the square's definition.

            flat.Add(ci2);

            // Create an instance of the square (which now includes the triangle).

            CompInst ci = new CompInst
            {
                ComponentName = "Flat",
                InstanceName  = "Quad the First"
            };

            // Add that instance of the square to the model.

            model.Add(ci);

            model.WriteSketchUpFile(path + @"\BackwardComponent.skp");
        }
        public override void Run(string path)
        {
            CompInst ci;

            Model model = new Model();

            // Define the root level.

            CompDef def = new CompDef(
                "Flat",
                "A Square");

            model.Add(def);

            Point3[] flatPoints =
            {
                new Point3(-1, 0, -1),
                new Point3(1,  0, -1),
                new Point3(1,  0,  1),
                new Point3(-1, 0, 1)
            };

            def.Add(flatPoints);

            // Two branches.

            ci = new CompInst
            {
                ComponentName = "Pointy",
                InstanceName  = "On the right."
            };

            ci.Transform.Translation.X = 3;
            ci.Transform.Translation.Z = 3;

            def.Add(ci);

            ci = new CompInst
            {
                ComponentName = "Pointy",
                InstanceName  = "On the left."
            };

            ci.Transform.Translation.X = -3;
            ci.Transform.Translation.Z = 3;

            def.Add(ci);

            ci = new CompInst
            {
                ComponentName = "Flat",
                InstanceName  = "At the origin."
            };

            model.Add(ci);

            CompDef pointy = new CompDef(
                "Pointy",
                "A Triangle");


            Point3[] pointyPoints =
            {
                new Point3(-1, 0, -1),
                new Point3(1,  0, -1),
                new Point3(0,  0, 1)
            };

            pointy.Add(pointyPoints);

            model.Add(pointy);

            // Two branches of its own.

            ci = new CompInst
            {
                ComponentName = "Skinny",
                InstanceName  = "On the far upper right."
            };

            ci.Transform.Translation.X = 3;
            ci.Transform.Translation.Z = 3;

            pointy.Add(ci);

            ci = new CompInst
            {
                ComponentName = "Skinny",
                InstanceName  = "On the far upper left."
            };

            ci.Transform.Translation.X = -3;
            ci.Transform.Translation.Z = 3;

            pointy.Add(ci);

            CompDef skinny = new CompDef(
                "Skinny",
                "A Slim Quad");

            Point3[] pts =
            {
                new Point3(-.2, 0, -1),
                new Point3(.2,  0, -1),
                new Point3(.2,  0,  1),
                new Point3(-.2, 0, 1)
            };

            skinny.Add(pts);

            model.Add(skinny);

            model.WriteSketchUpFile(path + @"\ThreePlyTree.skp");
        }