protected override void OnExecute(Command command, ExecutionContext context, System.Drawing.Rectangle buttonRect)
        {
            Part part = Window.ActiveWindow.Scene as Part;

            Debug.Assert(part != null);

            Double stepSize = 0.001;
            string tessellateLoftResolutionPropertyName = "Loft Tessellation Resolution";

            if (!part.Document.CustomProperties.ContainsKey(tessellateLoftResolutionPropertyName))
            {
                CustomProperty.Create(part.Document, tessellateLoftResolutionPropertyName, stepSize);
            }

            CustomProperty property;

            if (part.Document.CustomProperties.TryGetValue(tessellateLoftResolutionPropertyName, out property))
            {
                stepSize = (double)property.Value;
            }

            List <ITrimmedCurve> curves = new List <ITrimmedCurve>(Window.ActiveWindow.GetAllSelectedITrimmedCurves());

            if (curves.Count < 3)
            {
                return;
            }

            Point startPoint = curves[0].StartPoint;

            if (curves[1].StartPoint != startPoint)
            {
                if (curves[1].StartPoint != startPoint)
                {
                    curves[0] = CurveSegment.Create(curves[0].GetGeometry <Curve>(), Interval.Create(curves[0].Bounds.End, curves[0].Bounds.Start)); // TBD Figure out why we can't call ReverseCurves and debug
                }
                else
                {
                    curves[1] = CurveSegment.Create(curves[1].GetGeometry <Curve>(), Interval.Create(curves[1].Bounds.End, curves[1].Bounds.Start));
                }
            }

            for (int i = 2; i < curves.Count; i++)
            {
                if (curves[i].StartPoint != startPoint)
                {
                    curves[i] = CurveSegment.Create(curves[i].GetGeometry <Curve>(), Interval.Create(curves[i].Bounds.End, curves[i].Bounds.Start));
                }

                if (curves[i].StartPoint != startPoint)
                {
                    return;
                }
            }

            double endZ = double.NegativeInfinity;

            foreach (ITrimmedCurve curve in curves)
            {
                if (curve.EndPoint.Z > endZ)
                {
                    endZ = curve.EndPoint.Z;
                }
            }

            Plane  startPlane = Plane.Create(Frame.Create(startPoint, Direction.DirX, Direction.DirY));
            double cuttingZ   = startPoint.Z;
            List <List <Point> > curveSteps = new List <List <Point> >();
            List <List <Point> > insetSteps = new List <List <Point> >();

            while (true)
            {
                cuttingZ -= stepSize;
                if (cuttingZ < endZ)
                {
                    break;
                }

                Plane        cuttingPlane = Plane.Create(Frame.Create(Point.Create(startPoint.X, startPoint.Y, cuttingZ), Direction.DirX, Direction.DirY));
                List <Point> curvePoints  = new List <Point>();
                List <Point> planarPoints = new List <Point>();
                foreach (ITrimmedCurve curve in curves)
                {
                    ICollection <IntPoint <SurfaceEvaluation, CurveEvaluation> > surfaceIntersections = cuttingPlane.IntersectCurve(curve.GetGeometry <Curve>());
                    foreach (IntPoint <SurfaceEvaluation, CurveEvaluation> surfaceIntersection in surfaceIntersections)
                    {
                        Point point = surfaceIntersection.Point;
                        curvePoints.Add(point);

                        Point     projectedPoint = startPlane.ProjectPoint(point).Point;
                        Direction direction      = (projectedPoint - startPoint).Direction;
                        double    length         = CurveSegment.Create(curve.GetGeometry <Curve>(), Interval.Create(curve.Bounds.Start, surfaceIntersection.EvaluationB.Param)).Length;
                        planarPoints.Add(startPoint + direction * length);

                        break; // assume one intersection
                    }
                }

                List <Point> insetPoints = new List <Point>();
                for (int i = 0; i < planarPoints.Count; i++)
                {
                    int ii = i == planarPoints.Count - 1 ? 0 : i + 1;

                    ICollection <Point> pointCandidates = AddInHelper.IntersectSpheres(new Sphere[] {
                        Sphere.Create(Frame.Create(startPoint, Direction.DirX, Direction.DirY), ((startPoint - curvePoints[i]).Magnitude + (startPoint - curvePoints[ii]).Magnitude) / 2),
                        Sphere.Create(Frame.Create(curvePoints[i], Direction.DirX, Direction.DirY), (startPoint - curvePoints[i]).Magnitude),
                        Sphere.Create(Frame.Create(curvePoints[ii], Direction.DirX, Direction.DirY), (startPoint - curvePoints[ii]).Magnitude)
                    });

                    Point planarMidPoint = Point.Origin + (planarPoints[i] + planarPoints[ii].Vector).Vector / 2;
                    Point insetPoint;
                    foreach (Point point in pointCandidates)
                    {
                        Point testPoint = startPlane.ProjectPoint(point).Point;

                        if ((testPoint - planarMidPoint).Magnitude < (insetPoint - planarMidPoint).Magnitude)
                        {
                            insetPoint = point;
                        }
                    }

                    insetPoints.Add(insetPoint);
                }

                curveSteps.Add(curvePoints);
                insetSteps.Add(insetPoints);
            }

            for (int i = 0; i < curveSteps.Count - 1; i++)
            {
                for (int j = 0; j < curveSteps[i].Count; j++)
                {
                    int jj = j == curveSteps[i].Count - 1 ? 0 : j + 1;

                    ShapeHelper.CreatePolygon(new Point[] { curveSteps[i][j], curveSteps[i + 1][j], insetSteps[i][j] }, 0, null);
                    ShapeHelper.CreatePolygon(new Point[] { curveSteps[i + 1][j], insetSteps[i][j], insetSteps[i + 1][j] }, 0, null);
                    ShapeHelper.CreatePolygon(new Point[] { insetSteps[i][j], insetSteps[i + 1][j], curveSteps[i][jj] }, 0, null);
                    ShapeHelper.CreatePolygon(new Point[] { insetSteps[i + 1][j], curveSteps[i][jj], curveSteps[i + 1][jj] }, 0, null);
                }
            }

            return;
        }