Пример #1
0
        public static List <ICurve> GetXzCrossSectionCurves(this IBody2 body)
        {
            var modeler = SwAddinBase.Active.Modeler;
            var yZPlane = ((ISurface)modeler.CreatePlanarSurface2(new[] { 0, 0, 0.0 }, new[] { 1.0, 0, 0 }, new[] { 0, 0, 1.0 })).ToSheetBody();

            var cutBody = body
                          .CutBySheets(new[] { yZPlane })
                          .First(b => b.GetBodyBoxTs().XMax > 1e-5);

            var zXPlane = ((ISurface)modeler.CreatePlanarSurface2(new[] { 0, 0, 0.0 }, new[] { 0, 1.0, 0 }, new[] { 0, 0, 1.0 })).ToSheetBody();
            var edges   = cutBody.GetIntersectionEdgesNonDestructive(zXPlane)
                          //GetIntersectionEdges always returns the edges on the target and on the tool!
                          .Where((p, i) => i % 2 == 0)
                          .ToList();

            return(edges
                   .Select(e => e.GetCurveTs())
                   .Where(c => !(Math.Abs(c.StartPoint().X) < 1e-6 && Math.Abs(c.EndPoint().X) < 1e-6))
                   .Distinct()
                   .ToList());
        }