Example #1
0
        public void DrawGroup(CurveArray curves, string name)
        {
            ModelCurveArray roomShape = MakeModelCurve(curves);

            Autodesk.Revit.DB.Group group = _doc.Create.NewGroup(roomShape.Cast <ModelCurve>().Select(x => x.Id).ToList());
            group.GroupType.Name = name;
        }
Example #2
0
        //#region public properties

        ///// <summary>
        ///// Retrive a set of properties
        ///// for the Space
        ///// </summary>
        ///// <returns name="Name">The MEPSpace Name</returns>
        ///// <returns name="Number">The MEPSpace Number</returns>
        ///// <returns name="CustomRoom Name">The associated room Name</returns>
        ///// <returns name="CustomRoom Number">The associated room Number</returns>
        //[MultiReturn(new[] { "Name", "Number", "CustomRoom Number", "CustomRoom Name" })]
        //public Dictionary<string, string> IdentificationData()
        //{
        //    string roomName = "Unoccupied";
        //    string roomNumber = "Unoccupied";
        //    if (InternalGroup.CustomRoom != null)
        //    {
        //        roomName = InternalGroup.CustomRoom.Name;
        //        roomNumber = InternalGroup.CustomRoom.Number;
        //    }
        //    return new Dictionary<string, string>()
        //        {
        //            {"Name",InternalGroup.Name},
        //            {"Number",InternalGroup.Number},
        //            {"CustomRoom Name",roomName},
        //            {"CustomRoom Number",roomNumber}
        //        };
        //}

        ///// <summary>
        ///// Retrive space boundary elements
        ///// </summary>
        //public List<Element> BoundaryElements
        //{
        //    get
        //    {
        //        List<Element> output = new List<Element>();
        //        DB.Document doc = DocumentManager.Instance.CurrentDBDocument;
        //        DB.SpatialElementBoundaryOptions opt = new DB.SpatialElementBoundaryOptions();

        //        foreach (List<DB.BoundarySegment> segments in InternalGroup.GetBoundarySegments(opt))
        //        {
        //            foreach (DB.BoundarySegment segment in segments)
        //            {
        //                DB.Element boundaryElement = doc.GetElement(segment.ElementId);

        //                output.Add(ElementWrapper.ToDSType(boundaryElement, true));
        //            }

        //        }
        //        output = output.Distinct().ToList();
        //        return output;
        //    }
        //}

        //private List<Curve> _boundaryCurves = new List<Curve>();

        ///// <summary>
        ///// Retrive space boundary curves
        ///// </summary>
        //public List<Curve> BoundaryCurves
        //{
        //    get
        //    {
        //        return _boundaryCurves;
        //    }
        //}



        //#endregion

        #region Internal static constructors

        /// <summary>
        /// Create a group from an existing reference
        /// </summary>
        /// <param name="group"></param>
        /// <param name="isRevitOwned"></param>
        /// <returns></returns>
        internal static Group FromExisting(DB.Group group, bool isRevitOwned)
        {
            return(new Group(group)
            {
                //IsRevitOwned = isRevitOwned
            });
        }
Example #3
0
 /// <summary>
 /// Create a Group from a user selected Element.
 /// </summary>
 /// <param name="group"></param>
 /// <param name="isRevitOwned"></param>
 /// <returns></returns>
 internal static Group FromExisting(Autodesk.Revit.DB.Group group, bool isRevitOwned)
 {
     return(new Group(group)
     {
         IsRevitOwned = isRevitOwned
     });
 }
 public bool CanConvertToSpeckle(object @object)
 {
     return(@object
            switch
     {
         DB.DetailCurve _ => true,
         DB.DirectShape _ => true,
         DB.FamilyInstance _ => true,
         DB.Floor _ => true,
         DB.Level _ => true,
         DB.View _ => true,
         DB.ModelCurve _ => true,
         DB.Opening _ => true,
         DB.RoofBase _ => true,
         DB.Area _ => true,
         DB.Architecture.Room _ => true,
         DB.Architecture.TopographySurface _ => true,
         DB.Wall _ => true,
         DB.Mechanical.Duct _ => true,
         DB.Mechanical.Space _ => true,
         DB.Plumbing.Pipe _ => true,
         DB.Electrical.Wire _ => true,
         DB.CurtainGridLine _ => true, //these should be handled by curtain walls
         DB.Architecture.BuildingPad _ => true,
         DB.Architecture.Stairs _ => true,
         DB.Architecture.StairsRun _ => true,
         DB.Architecture.StairsLanding _ => true,
         DB.Architecture.Railing _ => true,
         DB.Architecture.TopRail _ => true,
         DB.Ceiling _ => true,
         DB.PointCloudInstance _ => true,
         DB.Group _ => true,
         DB.ProjectInfo _ => true,
         DB.ElementType _ => true,
         DB.Grid _ => true,
         DB.ReferencePoint _ => true,
         DB.Structure.AnalyticalModelStick _ => true,
         DB.Structure.AnalyticalModelSurface _ => true,
         DB.Structure.BoundaryConditions _ => true,
         _ => (@object as Element).IsElementSupported()
     });
        void ReconstructGroupByLocation
        (
            DB.Document doc,
            ref DB.Group element,

            [Description("Location where to place the group. Point or plane is accepted.")]
            Rhino.Geometry.Point3d location,
            DB.GroupType type,
            Optional <DB.Level> level
        )
        {
            var scaleFactor = 1.0 / Revit.ModelUnits;

            location = location.ChangeUnits(scaleFactor);

            if (!location.IsValid)
            {
                ThrowArgumentException(nameof(location), "Should be a valid point.");
            }

            SolveOptionalLevel(doc, location, ref level, out var bbox);

            ChangeElementTypeId(ref element, type.Id);

            if
            (
                element is DB.Group &&
                element.Location is DB.LocationPoint locationPoint &&
                locationPoint.Point.Z == location.Z
            )
            {
                var newOrigin = location.ToHost();
                if (!newOrigin.IsAlmostEqualTo(locationPoint.Point))
                {
                    element.Pinned      = false;
                    locationPoint.Point = newOrigin;
                    element.Pinned      = true;
                }
            }
Example #6
0
        void ReconstructGroupByLocation
        (
            DB.Document doc,
            ref DB.Group element,

            [Description("Location where to place the group.")]
            Rhino.Geometry.Point3d location,
            DB.GroupType type,
            Optional <DB.Level> level
        )
        {
            if (!location.IsValid)
            {
                ThrowArgumentException(nameof(location), "Should be a valid point.");
            }

            SolveOptionalLevel(doc, location, ref level, out var bbox);

            ChangeElementTypeId(ref element, type.Id);

            var newLocation = location.ToXYZ();

            if
            (
                element is DB.Group &&
                element.Location is DB.LocationPoint locationPoint &&
                locationPoint.Point.Z == newLocation.Z
            )
            {
                if (!newLocation.IsAlmostEqualTo(locationPoint.Point))
                {
                    element.Pinned      = false;
                    locationPoint.Point = newLocation;
                    element.Pinned      = true;
                }
            }
Example #7
0
 public Group(DB.Group value) : base(value)
 {
 }
Example #8
0
 /// <summary>
 /// Initialize a group element
 /// </summary>
 /// <param name="group">An existing Revit Group</param>
 private void InitGroup(DB.Group group)
 {
     InternalSetGroup(group);
 }
Example #9
0
 /// <summary>
 /// Create from an existing Revit Element
 /// </summary>
 /// <param name="group">An existing Revit Group</param>
 private Group(DB.Group group)
 {
     SafeInit(() => InitGroup(group));
 }
Example #10
0
 /// <summary>
 /// Set the internal Element, ElementId, and UniqueId
 /// </summary>
 /// <param name="group"></param>
 private void InternalSetGroup(DB.Group group)
 {
     InternalGroup     = group;
     InternalElementId = group.Id;
     InternalUniqueId  = group.UniqueId;
 }
Example #11
0
 /// <summary>
 /// Set the internal Element, ElementId, and UniqueId
 /// </summary>
 /// <param name="group"></param>
 private void InternalSetGroup(DB.Group group)
 {
     InternalGroup = group;
     InternalElementId = group.Id;
     InternalUniqueId = group.UniqueId;
 }
Example #12
0
 public static Group Wrap(Autodesk.Revit.DB.Group ele, bool isRevitOwned)
 {
     return(Group.FromExisting(ele, isRevitOwned));
 }
Example #13
0
 /// <summary>
 /// Initialize a group element
 /// </summary>
 private void InitGroup(Autodesk.Revit.DB.Group group)
 {
     InternalGroup     = group;
     InternalElementId = group.Id;
     InternalUniqueId  = group.UniqueId;
 }
Example #14
0
 /// <summary>
 /// Private constructor
 /// </summary>
 private Group(Autodesk.Revit.DB.Group group)
 {
     SafeInit(() => InitGroup(group));
 }