예제 #1
0
      /// <summary>
      /// Remove an element from the GUID to element id map, if its GUID is found in the map.
      /// </summary>
      /// <param name="elem">The element.</param>
      public void UseElement(Element elem)
      {
         if (elem == null)
            return;

         string guid = IFCGUIDUtil.GetGUID(elem);
         if (string.IsNullOrWhiteSpace(guid))
            return;

         GUIDToElementMap.Remove(guid);
      }
예제 #2
0
      /// <summary>
      /// Reuse an element from the GUID to element map, in a reload operation, if it exists.
      /// </summary>
      /// <typeparam name="T">The type of element.  We do type-checking for consistency.</typeparam>
      /// <param name="document">The document.</param>
      /// <param name="guid">The GUID.</param>
      /// <returns>The element from the map.</returns>
      public T UseElementByGUID<T>(Document document, string guid) where T : Element
      {
         T elementT = null;
         ElementId elementId;
         if (GUIDToElementMap.TryGetValue(guid, out elementId))
         {
            Element element = document.GetElement(elementId);
            if (element is T)
            {
               elementT = element as T;
               GUIDToElementMap.Remove(guid);
            }
         }

         return elementT;
      }