Example #1
0
 /// <summary>
 /// Return a default TextNoteType
 /// </summary>
 /// <returns></returns>
 public static TextNoteType Default()
 {
     Autodesk.Revit.DB.FilteredElementCollector collector = new Autodesk.Revit.DB.FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument).OfClass(typeof(Autodesk.Revit.DB.TextNoteType));
     return(FromExisting((Autodesk.Revit.DB.TextNoteType)collector.FirstOrDefault(), true));
 }
Example #2
0
        public void ByCircle_ValidArgs()
        {
            Autodesk.Revit.DB.FilteredElementCollector collector = new Autodesk.Revit.DB.FilteredElementCollector(Revit.Application.Document.Current.InternalDocument).OfClass(typeof(Autodesk.Revit.DB.FilledRegionType));
            FilledRegionType type = FilledRegionType.FromExisting((Autodesk.Revit.DB.FilledRegionType)collector.FirstOrDefault(), true);

            Assert.NotNull(type);

            Circle c = Circle.ByCenterPointRadius(Point.ByCoordinates(0, 0, 0), 10);

            Assert.NotNull(c);

            Curve[] curves = c.ApproximateWithArcAndLineSegments();

            // Approximate With Arc and Lines returns one Curve which is not closed. Seems odd.
            if (curves.Count() > 0 && curves[0].IsClosed)
            {
                var reg = FilledRegion.ByCurves(Revit.Application.Document.Current.ActiveView, curves, type);
                Assert.NotNull(reg);
            }
        }
Example #3
0
        public void ByElementAndOffset_ValidArgs()
        {
            var line = Line.ByStartPointEndPoint(Point.ByCoordinates(0, 0, 0), Point.ByCoordinates(1000, 0, 0));

            Assert.NotNull(line);

            Autodesk.Revit.DB.FilteredElementCollector collector = new Autodesk.Revit.DB.FilteredElementCollector(Revit.Application.Document.Current.InternalDocument).OfClass(typeof(Autodesk.Revit.DB.WallType));
            Revit.Elements.WallType wt = Revit.Elements.WallType.FromExisting((Autodesk.Revit.DB.WallType)collector.FirstOrDefault(), true);

            var wall = Wall.ByCurveAndHeight(line, 300, Level.ByElevation(100), wt);

            Assert.NotNull(wall);

            var tag = Tag.ByElementAndOffset(Revit.Application.Document.Current.ActiveView, wall, Vector.ByCoordinates(0, 0, 0));

            Assert.NotNull(tag);
            Assert.NotNull(tag.InternalElement);
            Assert.IsInstanceOf(typeof(Autodesk.Revit.DB.IndependentTag), tag.InternalElement);
            var itag = tag.InternalElement as Autodesk.Revit.DB.IndependentTag;

            itag.TagHeadPosition.DistanceTo(new Autodesk.Revit.DB.XYZ(500, 0, 0)).ShouldBeApproximately(0);
        }
Example #4
0
        public void ByCurves_ValidArgs()
        {
            Autodesk.Revit.DB.FilteredElementCollector collector = new Autodesk.Revit.DB.FilteredElementCollector(Revit.Application.Document.Current.InternalDocument).OfClass(typeof(Autodesk.Revit.DB.FilledRegionType));
            FilledRegionType type = FilledRegionType.FromExisting((Autodesk.Revit.DB.FilledRegionType)collector.FirstOrDefault(), true);

            Assert.NotNull(type);

            Polygon polygon = Polygon.RegularPolygon(Circle.ByCenterPointRadius(Point.ByCoordinates(0, 0, 0), 10), 4);

            Assert.NotNull(polygon);

            var reg = FilledRegion.ByCurves(Revit.Application.Document.Current.ActiveView, polygon.Curves().ToList(), type);

            Assert.NotNull(reg);
        }
Example #5
0
        public void ByElement_ValidArgs()
        {
            var line = Line.ByStartPointEndPoint(Point.ByCoordinates(0, 0, 0), Point.ByCoordinates(1000, 0, 0));

            Assert.NotNull(line);

            Autodesk.Revit.DB.FilteredElementCollector collector = new Autodesk.Revit.DB.FilteredElementCollector(Revit.Application.Document.Current.InternalDocument).OfClass(typeof(Autodesk.Revit.DB.WallType));
            Revit.Elements.WallType wt = Revit.Elements.WallType.FromExisting((Autodesk.Revit.DB.WallType)collector.FirstOrDefault(), true);

            var wall = Wall.ByCurveAndHeight(line, 300, Level.ByElevation(100), wt);

            Assert.NotNull(wall);

            var tag = Tag.ByElement(Revit.Application.Document.Current.ActiveView, wall, true, false, "Center", "Middle", Vector.ByCoordinates(0, 0, 0));

            Assert.NotNull(tag);
        }