Exemplo n.º 1
0
        public void ByViewAndFaceAnalysisData_BadArgs()
        {
            var surface = AnalysisDisplayHelpers.GetFirstSurfaceInInPlaceMass();

            var samplePoints = new[]
            {
                UV.ByCoordinates(0, 0),
                UV.ByCoordinates(0.5, 0),
                UV.ByCoordinates(0, 0.5)
            };

            var sampleValues = new[]
            {
                1.0,
                1092,
                -1
            };

            var data = SurfaceAnalysisData.BySurfacePointsAndResults(surface, samplePoints, new List <string>()
            {
                "Sample Data"
            }, new IList <double>[] { sampleValues });
            var doc = Document.Current;

            Assert.Throws(typeof(System.ArgumentNullException), () => FaceAnalysisDisplay.ByViewAndFaceAnalysisData(null, new [] { data }));
            Assert.Throws(typeof(System.ArgumentNullException), () => FaceAnalysisDisplay.ByViewAndFaceAnalysisData(doc.ActiveView, null));
            Assert.Throws(typeof(System.Exception), () => FaceAnalysisDisplay.ByViewAndFaceAnalysisData(doc.ActiveView, new SurfaceAnalysisData[] {}));
        }
Exemplo n.º 2
0
        public void ByViewAndFaceAnalysisData_ValidArgs()
        {
            var surface = AnalysisDisplayHelpers.GetFirstSurfaceInInPlaceMass();

            var samplePoints = new[]
            {
                UV.ByCoordinates(0, 0),
                UV.ByCoordinates(0.1, 0.2),
                UV.ByCoordinates(0, 0.1),
            };

            var sampleValues = new[]
            {
                1.0,
                1092,
                -1
            };

            var data = SurfaceAnalysisData.BySurfacePointsAndResults(surface, samplePoints, new List <string>()
            {
                "Sample Data"
            }, new IList <double>[] { sampleValues });

            var doc  = Document.Current;
            var grid = FaceAnalysisDisplay.ByViewAndFaceAnalysisData(doc.ActiveView, new [] { data });

            Assert.NotNull(grid);
        }
Exemplo n.º 3
0
        public void SurfaceAnalysisDataBySurfaceAndPoints_ValidArgs()
        {
            var sad = SurfaceAnalysisData.BySurfaceAndPoints(TestSurface(), TestUvs());

            Assert.NotNull(sad);
            Assert.NotNull(sad.Surface);
            Assert.NotNull(sad.CalculationLocations);
        }
Exemplo n.º 4
0
        public void SurfaceAnalysisDataBySurfacePointsAndResults_ValidArgs()
        {
            var sad = SurfaceAnalysisData.BySurfacePointsAndResults(
                TestSurface(),
                TestUvs(),
                TestResultNames(),
                TestResults());

            Assert.NotNull(sad);
            Assert.NotNull(sad.Surface);
            Assert.AreEqual(sad.Results.Count, 3);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Show a colored Face Analysis Display in the Revit view.
        /// </summary>
        /// <param name="view">The view into which you want to draw the analysis results.</param>
        /// <param name="sampleLocations">The locations at which you want to create analysis values.</param>
        /// <param name="samples">The analysis values at the given locations.</param>
        /// <param name="name">An optional analysis results name to show on the results legend.</param>
        /// <param name="description">An optional analysis results description to show on the results legend.</param>
        /// <param name="unitType">An optional Unit type to provide conversions in the analysis results.</param>
        /// <returns>A FaceAnalysisDisplay object.</returns>
        public static FaceAnalysisDisplay ByViewFacePointsAndValues(
            View view, Surface surface,
            Autodesk.DesignScript.Geometry.UV[] sampleLocations, double[] samples, string name = "", string description = "", Type unitType = null)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            if (surface == null)
            {
                throw new ArgumentNullException("surface");
            }

            if (sampleLocations == null)
            {
                throw new ArgumentNullException("sampleUvPoints");
            }

            if (samples == null)
            {
                throw new ArgumentNullException("samples");
            }

            if (sampleLocations.Length != samples.Length)
            {
                throw new Exception("The number of sample points and number of samples must be the same");
            }

            if (string.IsNullOrEmpty(name))
            {
                name = Resource1.AnalysisResultsDefaultName;
            }

            if (string.IsNullOrEmpty(description))
            {
                description = Resource1.AnalysisResultsDefaultDescription;
            }

            var data = SurfaceAnalysisData.BySurfacePointsAndResults(surface, sampleLocations.ToList(), new List <string> {
                "Dynamo Data"
            }, new List <IList <double> > {
                samples
            });

            return(new FaceAnalysisDisplay(view.InternalView, new ISurfaceAnalysisData <Autodesk.DesignScript.Geometry.UV, double>[] { data }, name, description, unitType));
        }
Exemplo n.º 6
0
        public void SurfaceAnalysisDataBySurfacePointAndResults_BadArgs()
        {
            Assert.Throws <ArgumentNullException>(() => SurfaceAnalysisData.BySurfacePointsAndResults(
                                                      null,
                                                      TestUvs(),
                                                      TestResultNames(),
                                                      TestResults()));

            Assert.Throws <ArgumentNullException>(() => SurfaceAnalysisData.BySurfacePointsAndResults(
                                                      TestSurface(),
                                                      null,
                                                      TestResultNames(),
                                                      TestResults()));

            Assert.Throws <ArgumentNullException>(() => SurfaceAnalysisData.BySurfacePointsAndResults(
                                                      TestSurface(),
                                                      TestUvs(),
                                                      null,
                                                      TestResults()));

            Assert.Throws <ArgumentNullException>(() => SurfaceAnalysisData.BySurfacePointsAndResults(
                                                      TestSurface(),
                                                      TestUvs(),
                                                      TestResultNames(),
                                                      null));

            // Test empty calculation set
            Assert.Throws <ArgumentException>(() => SurfaceAnalysisData.BySurfacePointsAndResults(
                                                  TestSurface(),
                                                  new List <UV>(),
                                                  TestResultNames(),
                                                  TestResults()));

            // Test non matching results sets
            Assert.Throws <ArgumentException>(() => SurfaceAnalysisData.BySurfacePointsAndResults(
                                                  TestSurface(),
                                                  TestUvs(),
                                                  new [] { "cat", "foo" },
                                                  TestResults()));
        }
Exemplo n.º 7
0
 public void SurfaceAnalysisDataBySurfaceAndPoints_BadArgs()
 {
     Assert.Throws <ArgumentNullException>(() => SurfaceAnalysisData.BySurfaceAndPoints(null, TestUvs()));
     Assert.Throws <ArgumentNullException>(() => SurfaceAnalysisData.BySurfaceAndPoints(TestSurface(), null));
 }
Exemplo n.º 8
0
        /// <summary>
        /// Show a colored Face Analysis Display in the Revit view.
        /// </summary>
        /// <param name="view">The view into which you want to draw the analysis results.</param>
        /// <param name="data">A collection of SurfaceAnalysisData objects.</param>
        /// <param name="name">An optional analysis results name to show on the results legend.</param>
        /// <param name="description">An optional analysis results description to show on the results legend.</param>
        /// <param name="unitType">An optional Unit type to provide conversions in the analysis results.</param>
        /// <returns>A FaceAnalysisDisplay object.</returns>
        public static FaceAnalysisDisplay ByViewAndFaceAnalysisData(
            View view, SurfaceAnalysisData[] data, string name = "", string description = "", Type unitType = null)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            if (data == null)
            {
                throw new ArgumentNullException("data");
            }

            if (!data.Any())
            {
                throw new Exception("There is no input data.");
            }

            if (string.IsNullOrEmpty(name))
            {
                name = Resource1.AnalysisResultsDefaultName;
            }

            if (string.IsNullOrEmpty(description))
            {
                description = Resource1.AnalysisResultsDefaultDescription;
            }

            return new FaceAnalysisDisplay(view.InternalView, data, name, description, unitType);
        }