Beispiel #1
0
        public void FloorSlabShapePoints_Edit()
        {
            var elevation = 100;
            var level     = Level.ByElevation(elevation);

            var outline = new[]
            {
                Line.ByStartPointEndPoint(Point.ByCoordinates(0, 0, 0), Point.ByCoordinates(100, 0, 0)),
                Line.ByStartPointEndPoint(Point.ByCoordinates(100, 0, 0), Point.ByCoordinates(100, 100, 0)),
                Line.ByStartPointEndPoint(Point.ByCoordinates(100, 100, 0), Point.ByCoordinates(0, 100, 0)),
                Line.ByStartPointEndPoint(Point.ByCoordinates(0, 100, 0), Point.ByCoordinates(0, 0, 0))
            };

            var floorType = FloorType.ByName("Generic - 12\"");

            var floor = Floor.ByOutlineTypeAndLevel(outline, floorType, level);

            Assert.NotNull(floor);


            floor.AddPoint(Point.ByCoordinates(50, 50, 0));
            Assert.IsTrue(floor.Points.ToList().Count == 5);

            double elev = floor.Points.First().Z;

            floor.MovePoint(floor.Points.First(), 10);

            floor.Points.First().Z.ShouldBeApproximately(elev + 10);
        }
Beispiel #2
0
        /// <exclude />
        private Element ToHorizontalFloor(FloorType floorType, Level level)
        {
            Utils.Log(string.Format("MultiPoint.ToHorizontalFloor started...", ""));

            try
            {
                if (!SessionVariables.ParametersCreated)
                {
                    UtilsObjectsLocation.CheckParameters(DocumentManager.Instance.CurrentDBDocument);
                }

                PolyCurve outline = PolyCurve.ByPoints(this.ShapePoints.Points.Select(p => p.RevitPoint).ToList(), true);

                outline = PolyCurve.ByJoinedCurves(outline.PullOntoPlane(Plane.XY()).Explode().Cast <Curve>().ToList());

                var output = Floor.ByOutlineTypeAndLevel(outline, floorType, level);

                output.SetParameterByName(ADSK_Parameters.Instance.MultiPoint.Name, SerializeJSON());

                Utils.Log(string.Format("MultiPoint.ToHorizontalFloor completed.", ""));

                return(output);
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("ERROR: MultiPoint.ToHorizontalFloor {0}", ex.Message));
                throw ex;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Converts the MultiPoint into a floor of the specified type.
        /// </summary>
        /// <param name="floorType">Type of the floor.</param>
        /// <param name="level">The level.</param>
        /// <param name="structural">if set to <c>true</c> [structural].</param>
        /// <returns></returns>
        public Element ToFloor(FloorType floorType, Level level, bool structural = true)
        {
            Utils.Log(string.Format("MultiPoint.ToFloor started...", ""));

            try
            {
                if (!SessionVariables.ParametersCreated)
                {
                    UtilsObjectsLocation.CheckParameters(DocumentManager.Instance.CurrentDBDocument);
                }

                PolyCurve outline = PolyCurve.ByPoints(this.ShapePoints.Points.Select(p => p.RevitPoint).ToList(), true);

                if (null == outline)
                {
                    System.Windows.Forms.MessageBox.Show("Outline is null");
                }

                Element output = null;

                try
                {
                    output = SlopedFloor.ByOutlineTypeAndLevel(outline, floorType, level, structural);
                }
                catch (Exception ex)
                {
                    Utils.Log(string.Format("ERROR: MultiPoint.ToFloor {0}", ex.Message));

                    output = Floor.ByOutlineTypeAndLevel(outline, floorType, level);
                }

                output.SetParameterByName(ADSK_Parameters.Instance.MultiPoint.Name, this.SerializeJSON());
                output.SetParameterByName(ADSK_Parameters.Instance.Update.Name, 1);
                output.SetParameterByName(ADSK_Parameters.Instance.Delete.Name, 0);

                Utils.Log(string.Format("MultiPoint.ToFloor completed.", ""));

                return(output);
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("ERROR: MultiPoint.ToFloor {0}", ex.Message));
                throw ex;
            }
        }
Beispiel #4
0
        public void ByOutlineTypeAndLevel_CurveArrayFloorTypeLevel_ThrowsExceptionWithNullArgument()
        {
            var elevation = 100;
            var level     = Level.ByElevation(elevation);

            var outline = new[]
            {
                Line.ByStartPointEndPoint(Point.ByCoordinates(0, 0, 0), Point.ByCoordinates(100, 0, 0)),
                Line.ByStartPointEndPoint(Point.ByCoordinates(100, 0, 0), Point.ByCoordinates(100, 100, 0)),
                Line.ByStartPointEndPoint(Point.ByCoordinates(100, 100, 0), Point.ByCoordinates(0, 100, 0)),
                Line.ByStartPointEndPoint(Point.ByCoordinates(0, 100, 0), Point.ByCoordinates(0, 0, 0))
            };

            var floorType = FloorType.ByName("Generic - 12\"");

            Assert.Throws(typeof(ArgumentNullException), () => Floor.ByOutlineTypeAndLevel(outline, null, level));
            Assert.Throws(typeof(ArgumentNullException), () => Floor.ByOutlineTypeAndLevel(outline, floorType, null));
        }
Beispiel #5
0
        public void ByOutlineTypeAndLevel_ValidArgs()
        {
            var elevation = 100;
            var level     = Level.ByElevation(elevation);

            var outline = new[]
            {
                Line.ByStartPointEndPoint(Point.ByCoordinates(0, 0, 0), Point.ByCoordinates(100, 0, 0)),
                Line.ByStartPointEndPoint(Point.ByCoordinates(100, 0, 0), Point.ByCoordinates(100, 100, 0)),
                Line.ByStartPointEndPoint(Point.ByCoordinates(100, 100, 0), Point.ByCoordinates(0, 100, 0)),
                Line.ByStartPointEndPoint(Point.ByCoordinates(0, 100, 0), Point.ByCoordinates(0, 0, 0))
            };

            var floorType = FloorType.ByName("Generic - 12\"");

            var floor = Floor.ByOutlineTypeAndLevel(outline, floorType, level);

            Assert.NotNull(floor);
        }
Beispiel #6
0
        public void ByOutlineTypeAndLevel_CurveArrayFloorTypeLevel_ProducesFloorWithCorrectArea()
        {
            var elevation = 100;
            var level     = Level.ByElevation(elevation);

            var outline = new[]
            {
                Line.ByStartPointEndPoint(Point.ByCoordinates(0, 0, 0), Point.ByCoordinates(100, 0, 0)),
                Line.ByStartPointEndPoint(Point.ByCoordinates(100, 0, 0), Point.ByCoordinates(100, 100, 0)),
                Line.ByStartPointEndPoint(Point.ByCoordinates(100, 100, 0), Point.ByCoordinates(0, 100, 0)),
                Line.ByStartPointEndPoint(Point.ByCoordinates(0, 100, 0), Point.ByCoordinates(0, 0, 0))
            };

            var floorType = FloorType.ByName("Generic - 12\"");

            var floor = Floor.ByOutlineTypeAndLevel(outline, floorType, level);

            BoundingBoxVolume(floor.BoundingBox).ShouldBeApproximately(100 * 100 * 0.3048, 1e-3);
        }
Beispiel #7
0
        public void CreateFoundationSlab_ByOutlineTypeAndLevel_CurveArrayFloorTypeLevel()
        {
            var elevation = 100;
            var level     = Level.ByElevation(elevation);

            var outline = new[]
            {
                Line.ByStartPointEndPoint(Point.ByCoordinates(0, 0, 0), Point.ByCoordinates(100, 0, 0)),
                Line.ByStartPointEndPoint(Point.ByCoordinates(100, 0, 0), Point.ByCoordinates(100, 100, 0)),
                Line.ByStartPointEndPoint(Point.ByCoordinates(100, 100, 0), Point.ByCoordinates(0, 100, 0)),
                Line.ByStartPointEndPoint(Point.ByCoordinates(0, 100, 0), Point.ByCoordinates(0, 0, 0))
            };

            var floorType = FloorType.ByName("6\" Foundation Slab");

            var floor = Floor.ByOutlineTypeAndLevel(outline, floorType, level);

            Assert.NotNull(floor);
            Assert.IsTrue(floor.InternalFloor.FloorType.IsFoundationSlab);
            Assert.AreEqual(floor.InternalFloor.FloorType.Name, "6\" Foundation Slab");
        }