Beispiel #1
0
        /// <summary>
        /// Mutate the name of the level
        /// </summary>
        /// <param name="name"> the name we want to set the level to have</param>
        /// <param name="oldname"> the oldname we tried to set this level to in the past,
        /// we retrieve this from trace</param>
        private void InternalSetName(string oldname, string name)
        {
            if (String.IsNullOrEmpty(name) ||
                string.CompareOrdinal(InternalLevel.Name, name) == 0 ||
                string.CompareOrdinal(oldname, name) == 0)
            {
                return;
            }
            //make a copy of the string
            var originalInputName = name;
            //Check to see whether there is an existing level with the same name
            var levels = ElementQueries.GetAllLevels();

            while (levels.Any(x => string.CompareOrdinal(x.Name, name) == 0))
            {
                //Update the level name
                Revit.Elements.InternalUtilities.ElementUtils.UpdateLevelName(ref name);
            }

            TransactionManager.Instance.EnsureInTransaction(Document);
            this.InternalLevel.Name = name;
            var updatedTraceData = new LevelTraceData(this, originalInputName);

            ElementBinder.SetRawDataForTrace(updatedTraceData);
            TransactionManager.Instance.TransactionTaskDone();
        }
Beispiel #2
0
        /// <summary>
        /// Mutate the name of the level
        /// </summary>
        /// <param name="name"></param>
        private void InternalSetName(string name)
        {
            if (String.IsNullOrEmpty(name) ||
                string.CompareOrdinal(InternalLevel.Name, name) == 0)
            {
                return;
            }

            //Check to see whether there is an existing level with the same name
            var levels = ElementQueries.GetAllLevels();

            while (levels.Any(x => string.CompareOrdinal(x.Name, name) == 0))
            {
                //Update the level name
                ElementUtils.UpdateLevelName(ref name);
            }

            TransactionManager.Instance.EnsureInTransaction(Document);
            this.InternalLevel.Name = name;
            TransactionManager.Instance.TransactionTaskDone();
        }
Beispiel #3
0
        public void GetAllLevels()
        {
            var levels = ElementQueries.GetAllLevels();

            Assert.AreEqual(levels.Count(), 1.0);
        }