Example #1
0
        public void ByPoints_PointArray_ProducesValidAdaptiveComponentAndLocations()
        {
            var pts = new Point[][]
            {
                new Point[]
                {
                    Point.ByCoordinates(0, 0, 0),
                    Point.ByCoordinates(10, 0, 10),
                    Point.ByCoordinates(20, 0, 0)
                }
            };
            var fs = FamilyType.ByName("3PointAC");
            var ac = AdaptiveComponent.ByPoints(pts, fs);

            var locs = ac.First().Locations;

            var pairs = locs.Zip(pts.First(), (point, point1) => new Tuple <Point, Point>(point, point1));

            // compares after unit conversion
            foreach (var pair in pairs)
            {
                pair.Item1.ShouldBeApproximately(pair.Item2);
            }

            var unconvertedPairs = pts.First().Zip(GetInternalPoints((FamilyInstance)ac.First().InternalElement),
                                                   (point, point1) => new Tuple <Point, XYZ>(point, point1));

            foreach (var pair in unconvertedPairs)
            {
                pair.Item1.ShouldBeApproximately(pair.Item2 * UnitConverter.HostToDynamoFactor(SpecTypeId.Length));
            }

            Assert.NotNull(ac);
        }