Exemplo n.º 1
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 (InternalGroupType.CustomRoom != null)
        //    {
        //        roomName = InternalGroupType.CustomRoom.Name;
        //        roomNumber = InternalGroupType.CustomRoom.Number;
        //    }
        //    return new Dictionary<string, string>()
        //        {
        //            {"Name",InternalGroupType.Name},
        //            {"Number",InternalGroupType.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 InternalGroupType.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 space from an existing reference
        /// </summary>
        /// <param name="GroupType"></param>
        /// <param name="isRevitOwned"></param>
        /// <returns></returns>
        internal static GroupType FromExisting(DB.GroupType GroupType, bool isRevitOwned)
        {
            return(new GroupType(GroupType)
            {
                //IsRevitOwned = isRevitOwned
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// Place a Group in the model
        /// </summary>
        /// <param name="point">The group instance location</param>
        /// <param name="groupType">The type of the group</param>
        private void InitGroup(DB.XYZ point, DB.GroupType groupType)
        {
            DB.Document document = DocumentManager.Instance.CurrentDBDocument;

            // This creates a new wall and deletes the old one
            TransactionManager.Instance.EnsureInTransaction(document);

            //Phase 1 - Check to see if the object exists and should be rebound
            var groupElem = ElementBinder.GetElementFromTrace <DB.Group>(document);

            if (groupElem == null)
            {
                groupElem = document.Create.PlaceGroup(point, groupType);
            }

            InternalSetGroup(groupElem);

            TransactionManager.Instance.TransactionTaskDone();

            if (groupElem != null)
            {
                ElementBinder.CleanupAndSetElementForTrace(document, this.InternalElement);
            }
            else
            {
                ElementBinder.SetElementForTrace(this.InternalElement);
            }
        }
Exemplo n.º 3
0
 public RenameParameter(Autodesk.Revit.DB.GroupType group)
 {
     this.Parameter = null;
     this.Category  = BuiltInCategory.INVALID;
     this.Type      = null;
     this.Family    = null;
     this.Group     = group;
     this.Name      = "Name";
 }
Exemplo n.º 4
0
 public RenameCandidate(Autodesk.Revit.DB.GroupType group)
 {
     this.parameter = null;
     this.note      = null;
     this.family    = null;
     this.group     = group;
     this.oldValue  = group.Name;
     this.newValue  = group.Name;
 }
Exemplo n.º 5
0
 public RenameCandidate(Family family)
 {
     this.parameter = null;
     this.note      = null;
     this.family    = family;
     this.oldValue  = family.Name;
     this.newValue  = family.Name;
     this.group     = null;
 }
Exemplo n.º 6
0
 public RenameCandidate(TextElement note)
 {
     this.parameter = null;
     this.note      = note;
     this.family    = null;
     this.group     = null;
     this.oldValue  = note.Text;
     this.newValue  = note.Text;
 }
Exemplo n.º 7
0
 public RenameCandidate(Parameter parameter)
 {
     this.parameter = parameter;
     this.note      = null;
     this.family    = null;
     this.group     = null;
     this.oldValue  = parameter.AsString();
     this.newValue  = parameter.AsString();
 }
Exemplo n.º 8
0
        void ReconstructGroupTypeCreate
        (
            DB.Document doc,
            ref DB.GroupType groupType,

            IList <DB.Element> elements,
            Optional <string> name
        )
        {
            var elementIds = DB.ElementTransformUtils.CopyElements(doc, elements.Where(x => x.Document.Equals(doc)).Select(x => x.Id).ToList(), DB.XYZ.Zero);

            if (groupType is DB.GroupType oldGroupType)
            {
                // To avoid name conflicts we rename the old GroupType that will be deleted
                oldGroupType.Name = Guid.NewGuid().ToString();

                var newGroup = doc.IsFamilyDocument ?
                               doc.FamilyCreate.NewGroup(elementIds):
                               doc.Create.NewGroup(elementIds);
                groupType = newGroup.GroupType;
                doc.Delete(newGroup.Id);

                // Update other occurrences of oldGroupType
                foreach (var twinGroup in oldGroupType.Groups.Cast <DB.Group>())
                {
                    twinGroup.GroupType = groupType;
                }
            }
            else
            {
                var newGroup = doc.IsFamilyDocument ?
                               doc.FamilyCreate.NewGroup(elementIds) :
                               doc.Create.NewGroup(elementIds);
                groupType = newGroup.GroupType;
                doc.Delete(newGroup.Id);
            }

            if (groupType is object && name.HasValue)
            {
                try { groupType.Name = name.Value; }
                catch (Autodesk.Revit.Exceptions.ArgumentException e)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, $"{e.Message.Replace($".{Environment.NewLine}", ". ")}");
                }
            }
        }
Exemplo n.º 9
0
        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;
                }
            }
Exemplo n.º 10
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;
                }
            }
Exemplo n.º 11
0
 private Group(DB.XYZ point, DB.GroupType groupType)
 {
     SafeInit(() => InitGroup(point, groupType));
 }
Exemplo n.º 12
0
 /// <summary>
 /// Initialize a GroupType element
 /// </summary>
 /// <param name="GroupType">An existing Revit GroupType</param>
 private void InitGroupType(DB.GroupType GroupType)
 {
     InternalSetGroupType(GroupType);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Create from an existing Revit Element
 /// </summary>
 /// <param name="GroupType">An existing Revit GroupType</param>
 private GroupType(DB.GroupType GroupType)
 {
     SafeInit(() => InitGroupType(GroupType));
 }
Exemplo n.º 14
0
 /// <summary>
 /// Set the internal Element, ElementId, and UniqueId
 /// </summary>
 /// <param name="GroupType"></param>
 private void InternalSetGroupType(DB.GroupType GroupType)
 {
     InternalGroupType = GroupType;
     InternalElementId = GroupType.Id;
     InternalUniqueId  = GroupType.UniqueId;
 }
Exemplo n.º 15
0
 /// <summary>
 /// Set the internal Element, ElementId, and UniqueId
 /// </summary>
 /// <param name="GroupType"></param>
 private void InternalSetGroupType(DB.GroupType GroupType)
 {
     InternalGroupType = GroupType;
     InternalElementId = GroupType.Id;
     InternalUniqueId = GroupType.UniqueId;
 }