Esempio n. 1
0
        /// <summary>
        /// Delete an element from the current document given the ElementUUID
        /// </summary>
        /// <param name="element">The UUID of the element to delete</param>
        public void DeleteElement(ElementUUID element)
        {
            TransactionManager.Instance.EnsureInTransaction(CurrentDBDocument);

            CurrentDBDocument.Delete(ElementBinder.GetIdForUUID(CurrentDBDocument, element));

            TransactionManager.Instance.TransactionTaskDone();
        }
Esempio n. 2
0
        /// <summary>
        /// Get the elementId associated with a UUID, possibly expensive
        /// </summary>
        /// <param name="document"></param>
        /// <param name="uuid"></param>
        /// <returns></returns>
        public static ElementId GetIdForUUID(Document document, ElementUUID uuid)
        {
            Element e = document.GetElement(uuid.UUID);

            if (e != null)
            {
                return(e.Id);
            }
            return(null);
        }
Esempio n. 3
0
        /// <summary>
        /// Set the element associated with the current operation from trace
        /// null if there is no object, or it's of the wrong type etc.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static void SetElementForTrace(ElementId elementId, ElementUUID elementUUID)
        {
            if (IsEnabled)
            {
                SerializableId id = new SerializableId();
                id.IntID    = elementId.IntegerValue;
                id.StringID = elementUUID.UUID;

                // if we're mutating the current Element id, that means we need to
                // clean up the old object

                // Set the element ID cached in the callsite
                TraceUtils.SetTraceData(REVIT_TRACE_ID, id);
            }
        }
        /// <summary>
        /// Delete an element from the current document given the ElementUUID
        /// </summary>
        /// <param name="element">The UUID of the element to delete</param>
        public void DeleteElement(ElementUUID element)
        {
            ElementId id = ElementBinder.GetIdForUUID(CurrentDBDocument, element);

            if (null != id)
            {
                TransactionManager.Instance.EnsureInTransaction(CurrentDBDocument);
                try
                {
                    CurrentDBDocument.Delete(id);
                }
                catch (Exception e)
                {
                    var ele = CurrentDBDocument.GetElement(id);
                    throw new ArgumentException(String.Format("This Element {0} {1} cannot be deleted", ele.ToString(), ele.Name));
                }

                TransactionManager.Instance.TransactionTaskDone();
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Determine if Element exists in the current document
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool ElementExistsInDocument(ElementUUID id)
        {
            Element e;

            return(CurrentDBDocument.TryGetElement(id.UUID, out e));
        }
Esempio n. 6
0
 /// <summary>
 /// Get the elementId associated with a UUID, possibly expensive
 /// </summary>
 /// <param name="document"></param>
 /// <param name="uuid"></param>
 /// <returns></returns>
 public static ElementId GetIdForUUID(Document document, ElementUUID uuid)
 {
     return(document.GetElement(uuid.UUID).Id);
 }