/// <summary> /// Perform end of import/link cleanup. /// </summary> /// <param name="doc">The document.</param> /// <param name="fileName">The full path of the original IFC file.</param> public void EndImport(Document doc, string fileName) { // Remove an unupdated Elements as a result of a reload operation. try { // We are working around a limitation in deleting unused DirectShapeTypes. IList <ElementId> otherElementsToDelete = new List <ElementId>(); IList <ElementId> typesToDelete = new List <ElementId>(); foreach (ElementId elementId in Importer.TheCache.GUIDToElementMap.Values) { if (DontDeleteSpecialElement(elementId)) { continue; } Element element = doc.GetElement(elementId); if (element == null) { continue; } if (element is DirectShapeType) { typesToDelete.Add(elementId); } else { otherElementsToDelete.Add(elementId); } } foreach (ElementId elementId in Importer.TheCache.GridNameToElementMap.Values) { Element element = doc.GetElement(elementId); if (element == null) { continue; } otherElementsToDelete.Add(elementId); } // Don't expect this to fail. try { if (otherElementsToDelete.Count > 0) { doc.Delete(otherElementsToDelete); } } catch (Exception ex) { TheLog.LogError(-1, ex.Message, false); } // Delete the temporary element we used for validation purposes. IFCGeometryUtil.DeleteSolidValidator(); // This might fail. if (typesToDelete.Count > 0) { doc.Delete(typesToDelete); } UpdateDocumentFileMetrics(doc, fileName); } catch // (Exception ex) { // Catch, but don't report, since this is an internal limitation in the API. //TheLog.LogError(-1, ex.Message, false); } if (m_Transaction != null) { m_Transaction.Commit(); } }