/// <summary> /// Create geometry for a particular representation item. /// </summary> /// <param name="shapeEditScope">The geometry creation scope.</param> /// <param name="lcs">Local coordinate system for the geometry.</param> /// <param name="scaledLcs">Local coordinate system for the geometry, including scale, potentially non-uniform.</param> /// <param name="guid">The guid of an element for which represntation is being created.</param> override protected void CreateShapeInternal(IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid) { if (XYZPoint == null) { return; } XYZ transformedPoint = scaledLcs.OfPoint(XYZPoint); if (transformedPoint == null) { return; } ElementId gstyleId = shapeEditScope.GraphicsStyleId; Category pointCategory = IFCCategoryUtil.GetSubCategoryForRepresentation(shapeEditScope.Document, Id, shapeEditScope.ContainingRepresentation.Identifier); if (pointCategory != null) { GraphicsStyle graphicsStyle = pointCategory.GetGraphicsStyle(GraphicsStyleType.Projection); if (graphicsStyle != null) { gstyleId = graphicsStyle.Id; } } Point point = Point.Create(transformedPoint, gstyleId); if (point == null) { return; } shapeEditScope.AddGeometry(IFCSolidInfo.Create(Id, point)); }
private void CreateBoxShape(IFCImportShapeEditScope shapeEditScope, Transform scaledLcs) { using (IFCImportShapeEditScope.IFCContainingRepresentationSetter repSetter = new IFCImportShapeEditScope.IFCContainingRepresentationSetter(shapeEditScope, this)) { // Get the material and graphics style based in the "Box" sub-category of Generic Models. // We will create the sub-category if this is our first time trying to use it. // Note that all bounding boxes are controlled by a sub-category of Generic Models. We may revisit that decision later. // Note that we hard-wire the identifier to "Box" because older files may have bounding box items in an obsolete representation. SolidOptions solidOptions = null; Category bboxCategory = IFCCategoryUtil.GetSubCategoryForRepresentation(shapeEditScope.Document, Id, IFCRepresentationIdentifier.Box); if (bboxCategory != null) { ElementId materialId = (bboxCategory.Material == null) ? ElementId.InvalidElementId : bboxCategory.Material.Id; GraphicsStyle graphicsStyle = bboxCategory.GetGraphicsStyle(GraphicsStyleType.Projection); ElementId gstyleId = (graphicsStyle == null) ? ElementId.InvalidElementId : graphicsStyle.Id; solidOptions = new SolidOptions(materialId, gstyleId); } Solid bboxSolid = IFCGeometryUtil.CreateSolidFromBoundingBox(scaledLcs, BoundingBox, solidOptions); if (bboxSolid != null) { IFCSolidInfo bboxSolidInfo = IFCSolidInfo.Create(Id, bboxSolid); shapeEditScope.AddGeometry(bboxSolidInfo); } } return; }
/// <summary> /// Processes IfcObjectDefinition attributes. /// </summary> /// <param name="ifcObjectDefinition">The IfcObjectDefinition handle.</param> protected override void Process(IFCAnyHandle ifcObjectDefinition) { base.Process(ifcObjectDefinition); ShapeType = GetShapeType(ifcObjectDefinition); // If we aren't importing this category, skip processing. if (!IFCCategoryUtil.CanImport(EntityType, ShapeType)) { throw new InvalidOperationException("Don't Import"); } // Before IFC2x3, IfcTypeObject did not have IsDecomposedBy. HashSet <IFCAnyHandle> elemSet = null; if (IFCImportFile.TheFile.SchemaVersion >= IFCSchemaVersion.IFC2x3 || !IFCAnyHandleUtil.IsSubTypeOf(ifcObjectDefinition, IFCEntityType.IfcTypeObject)) { elemSet = IFCAnyHandleUtil.GetAggregateInstanceAttribute <HashSet <IFCAnyHandle> >(ifcObjectDefinition, "IsDecomposedBy"); } if (elemSet != null) { foreach (IFCAnyHandle elem in elemSet) { ProcessIFCRelDecomposes(elem); } } HashSet <IFCAnyHandle> hasAssociations = IFCAnyHandleUtil.GetAggregateInstanceAttribute <HashSet <IFCAnyHandle> >(ifcObjectDefinition, "HasAssociations"); if (hasAssociations != null) { foreach (IFCAnyHandle hasAssociation in hasAssociations) { if (IFCAnyHandleUtil.IsSubTypeOf(hasAssociation, IFCEntityType.IfcRelAssociatesMaterial)) { ProcessIFCRelAssociatesMaterial(hasAssociation); } else { IFCImportFile.TheLog.LogUnhandledSubTypeError(hasAssociation, IFCEntityType.IfcRelAssociates, false); } } } // The default IFC2x3_TC1.exp file does not have this INVERSE attribute correctly set. Encapsulate this function. ISet <IFCAnyHandle> hasAssignments = IFCImportHandleUtil.GetHasAssignments(ifcObjectDefinition); if (hasAssignments != null) { foreach (IFCAnyHandle hasAssignment in hasAssignments) { ProcessIFCRelAssigns(hasAssignment); } } IFCImportFile.TheLog.AddToElementCount(); }
/// <summary> /// The main entry point into the .NET IFC import code /// </summary> /// <param name="importer">The internal ImporterIFC class that contains information necessary for the import process.</param> public void ImportIFC(ImporterIFC importer) { TheImporter = this; IDictionary <String, String> options = importer.GetOptions(); TheOptions = m_ImportOptions = IFCImportOptions.Create(options); // An early check, based on the options set - if we are allowed to use an up-to-date existing file on disk, use it. try { string fullIFCFileName = importer.FullFileName; if (!TheOptions.ForceImport && !NeedsReload(importer.Document, fullIFCFileName)) { return; } // Clear the category mapping table, to force reload of options. IFCCategoryUtil.Clear(); if (TheOptions.Intent != IFCImportIntent.Reference) { IFCImportFile.Import(importer); } else { ReferenceIFC(importer.Document, fullIFCFileName, options); } } catch (Exception ex) { if (Importer.TheLog != null) { Importer.TheLog.LogError(-1, ex.Message, false); } // The following message can sometimes occur when reloading some IFC files // from external resources. In this case, we should silently fail, and not // throw. if (!ex.Message.Contains("Starting a new transaction is not permitted")) { throw; } } finally { if (Importer.TheLog != null) { Importer.TheLog.Close(); } if (IFCImportFile.TheFile != null) { IFCImportFile.TheFile.Close(); } } }
protected virtual void CreateParametersInternal(Document doc, Element element) { if (element != null) { // Set the element name. SetName(doc, element); // Set the element description. SetDescription(doc, element); // The list of materials. SetMaterialParameter(doc, element); // Set the "IfcSystem" parameter. SetSystemParameter(doc, element); // Set the element GUID. bool elementIsType = (element is ElementType); BuiltInParameter ifcGUIDId = GetGUIDParameter(element, elementIsType); Parameter guidParam = element.get_Parameter(ifcGUIDId); if (guidParam != null) { if (!guidParam.IsReadOnly) { guidParam.Set(GlobalId); } } else { ExporterIFCUtils.AddValueString(element, new ElementId(ifcGUIDId), GlobalId); } // Set the "IfcExportAs" parameter. string ifcExportAs = IFCCategoryUtil.GetCustomCategoryName(this); if (!string.IsNullOrWhiteSpace(ifcExportAs)) { IFCPropertySet.AddParameterString(doc, element, "IfcExportAs", ifcExportAs, Id); } // Add property set-based parameters. // We are going to create this "fake" parameter so that we can filter elements in schedules based on their property sets. string propertySetListName = elementIsType ? "Type IfcPropertySetList" : "IfcPropertySetList"; IFCPropertySet.AddParameterString(doc, element, propertySetListName, "", Id); // Set the IFCElementAssembly Parameter if (Decomposes != null && Decomposes is IFCElementAssembly) { IFCPropertySet.AddParameterString(doc, element, "IfcElementAssembly", Decomposes.Name, Id); } } }
/// <summary> /// The main entry point into the .NET IFC import code /// </summary> /// <param name="importer">The internal ImporterIFC class that contains information necessary for the import process.</param> public void ImportIFC(ImporterIFC importer) { TheImporter = this; IDictionary <String, String> options = importer.GetOptions(); TheOptions = m_ImportOptions = IFCImportOptions.Create(options); // An early check, based on the options set - if we are allowed to use an up-to-date existing file on disk, use it. try { string fullFileName = importer.FullFileName; string revitFileName = IFCImportFile.GetRevitFileName(fullFileName); if (!TheOptions.ForceImport && !NeedsReload(fullFileName, revitFileName)) { return; } // Clear the category mapping table, to force reload of options. IFCCategoryUtil.Clear(); if (TheOptions.Intent != IFCImportIntent.Reference) { IFCImportFile.Import(importer); } else { ReferenceIFC(importer.Document, fullFileName, options); } } catch (Exception ex) { if (Importer.TheLog != null) { Importer.TheLog.LogError(-1, ex.Message, false); } } finally { if (Importer.TheLog != null) { Importer.TheLog.Close(); } if (IFCImportFile.TheFile != null) { IFCImportFile.TheFile.Close(); } } }
/// <summary> /// Create one or more elements /// </summary> /// <param name="doc">The document being populated.</param> /// <returns>The primary element associated with the IFCObjectDefinition, or InvalidElementId if it failed.</returns> public static ElementId CreateElement(Document doc, IFCObjectDefinition objDef) { // This would be a good place to check 'objDef.GlobalId'. ElementId createdElementId = objDef.CreatedElementId; try { if ((createdElementId == ElementId.InvalidElementId) && objDef.IsValidForCreation) { ElementId gstyleId; objDef.CategoryId = IFCCategoryUtil.GetCategoryIdForEntity(doc, objDef, out gstyleId); objDef.m_GraphicsStyleId = gstyleId; if (objDef is IFCObject) { IFCObject asObject = objDef as IFCObject; foreach (IFCTypeObject typeObject in asObject.TypeObjects) { IFCObjectDefinition.CreateElement(doc, typeObject); } } objDef.Create(doc); objDef.CreateParameters(doc); createdElementId = objDef.CreatedElementId; IFCImportFile.TheLog.AddCreatedEntity(doc, objDef); if (IFCImportFile.CleanEntitiesAfterCreate) { objDef.CleanEntity(); } } } catch (Exception ex) { if (objDef != null) { objDef.IsValidForCreation = false; IFCImportFile.TheLog.LogCreationError(objDef, ex.Message, false); } } return(createdElementId); }
protected virtual void CreateParametersInternal(Document doc, Element element) { if (element != null) { // Set the element name. SetName(doc, element); // Set the element description. SetDescription(doc, element); // The list of materials. SetMaterialParameter(doc, element); // Set the "IfcSystem" parameter. SetSystemParameter(doc, element); // Set the element GUID. bool elementIsType = (element is ElementType); BuiltInParameter ifcGUIDId = GetGUIDParameter(element, elementIsType); Parameter guidParam = element.get_Parameter(ifcGUIDId); if (guidParam != null) { if (!guidParam.IsReadOnly) { guidParam.Set(GlobalId); } } else { ExporterIFCUtils.AddValueString(element, new ElementId(ifcGUIDId), GlobalId); } // Set the "IfcExportAs" parameter. string ifcExportAs = IFCCategoryUtil.GetCustomCategoryName(this); if (!string.IsNullOrWhiteSpace(ifcExportAs)) { IFCPropertySet.AddParameterString(doc, element, "IfcExportAs", ifcExportAs, Id); } // Add property set-based parameters. // We are going to create this "fake" parameter so that we can filter elements in schedules based on their property sets. string propertySetListName = elementIsType ? "Type IfcPropertySetList" : "IfcPropertySetList"; IFCPropertySet.AddParameterString(doc, element, propertySetListName, "", Id); // Set the IFCElementAssembly Parameter if (Decomposes != null && Decomposes is IFCElementAssembly) { IFCPropertySet.AddParameterString(doc, element, "IfcElementAssembly", Decomposes.Name, Id); } // Set additional parameters (if any), e.g. for Classification assignments if (AdditionalIntParameters.Count > 0) { foreach (KeyValuePair <string, object> parItem in AdditionalIntParameters) { if (parItem.Value is string) { IFCPropertySet.AddParameterString(doc, element, parItem.Key, (string)parItem.Value, Id); } else if (parItem.Value is double) { IFCPropertySet.AddParameterDouble(doc, element, parItem.Key, UnitType.UT_Custom, (double)parItem.Value, Id); } else if (parItem.Value is int) { IFCPropertySet.AddParameterInt(doc, element, parItem.Key, (int)parItem.Value, Id); } else if (parItem.Value is bool) { IFCPropertySet.AddParameterBoolean(doc, element, parItem.Key, (bool)parItem.Value, Id); } } } } }
/// <summary> /// Processes IfcObjectDefinition attributes. /// </summary> /// <param name="ifcObjectDefinition">The IfcObjectDefinition handle.</param> protected override void Process(IFCAnyHandle ifcObjectDefinition) { base.Process(ifcObjectDefinition); PredefinedType = GetPredefinedType(ifcObjectDefinition); // If we aren't importing this category, skip processing. if (!IFCCategoryUtil.CanImport(EntityType, PredefinedType)) { throw new InvalidOperationException("Don't Import"); } // Before IFC2x3, IfcTypeObject did not have IsDecomposedBy. HashSet <IFCAnyHandle> elemSet = null; if (IFCImportFile.TheFile.SchemaVersionAtLeast(IFCSchemaVersion.IFC2x3) || !IFCAnyHandleUtil.IsSubTypeOf(ifcObjectDefinition, IFCEntityType.IfcTypeObject)) { elemSet = IFCAnyHandleUtil.GetAggregateInstanceAttribute <HashSet <IFCAnyHandle> >(ifcObjectDefinition, "IsDecomposedBy"); } if (elemSet != null) { foreach (IFCAnyHandle elem in elemSet) { ProcessIFCRelDecomposes(elem); } } HashSet <IFCAnyHandle> hasAssociations = IFCAnyHandleUtil.GetAggregateInstanceAttribute <HashSet <IFCAnyHandle> >(ifcObjectDefinition, "HasAssociations"); if (hasAssociations != null) { foreach (IFCAnyHandle hasAssociation in hasAssociations) { if (IFCAnyHandleUtil.IsSubTypeOf(hasAssociation, IFCEntityType.IfcRelAssociatesMaterial)) { ProcessIFCRelAssociatesMaterial(hasAssociation); } else if (IFCAnyHandleUtil.IsSubTypeOf(hasAssociation, IFCEntityType.IfcRelAssociatesClassification)) { ProcessRelAssociatesClassification(hasAssociation); } else { Importer.TheLog.LogUnhandledSubTypeError(hasAssociation, IFCEntityType.IfcRelAssociates, false); } } } ISet <IFCAnyHandle> hasAssignments = IFCAnyHandleUtil.GetAggregateInstanceAttribute <HashSet <IFCAnyHandle> >(ifcObjectDefinition, "HasAssignments"); if (hasAssignments != null) { foreach (IFCAnyHandle hasAssignment in hasAssignments) { ProcessIFCRelAssigns(hasAssignment); } } Importer.TheLog.AddToElementCount(); }
protected virtual void CreateParametersInternal(Document doc, Element element) { if (element != null) { Category category = IFCPropertySet.GetCategoryForParameterIfValid(element, Id); Importer.TheProcessor.CreateOrUpdateElement(Id, GlobalId, EntityType.ToString(), CategoryId.IntegerValue, null); // Set the element name. SetName(doc, element, category); // Set the element description. SetDescription(doc, element, category); // The list of materials. SetMaterialParameter(doc, element, category); // Set the "IfcSystem" parameter. SetSystemParameter(doc, element, category); bool elementIsType = (element is ElementType); if (!string.IsNullOrWhiteSpace(GlobalId)) { BuiltInParameter ifcGUIDId = GetGUIDParameter(element, elementIsType); Importer.TheProcessor.SetStringParameter(element, Id, ifcGUIDId, GlobalId, true); } // Set the built-in parameters. (string entityName, string predefinedType) = IFCCategoryUtil.GetEntityNameAndPredefinedType(this); if (!string.IsNullOrWhiteSpace(entityName)) { BuiltInParameter ifcExportElementAsParam = elementIsType ? BuiltInParameter.IFC_EXPORT_ELEMENT_TYPE_AS : BuiltInParameter.IFC_EXPORT_ELEMENT_AS; Importer.TheProcessor.SetStringParameter(element, Id, ifcExportElementAsParam, entityName, true); } if (!string.IsNullOrWhiteSpace(predefinedType)) { BuiltInParameter ifcPredefinedTypeParam = elementIsType ? BuiltInParameter.IFC_EXPORT_PREDEFINEDTYPE_TYPE : BuiltInParameter.IFC_EXPORT_PREDEFINEDTYPE; Importer.TheProcessor.SetStringParameter(element, Id, ifcPredefinedTypeParam, predefinedType, true); } // Set the IFCElementAssembly Parameter if (Decomposes != null) { string containerParamName = (Decomposes is IFCElementAssembly) ? "IfcElementAssembly" : "IfcDecomposes"; string containerParamGUIDName = (Decomposes is IFCElementAssembly) ? "IfcElementAssemblyGUID" : "IfcDecomposesGUID"; IFCPropertySet.AddParameterString(doc, element, category, this, containerParamName, Decomposes.Name, Id); IFCPropertySet.AddParameterString(doc, element, category, this, containerParamGUIDName, Decomposes.GlobalId, Id); } // Set additional parameters (if any), e.g. for Classification assignments if (AdditionalIntParameters.Count > 0) { foreach (KeyValuePair <string, object> parItem in AdditionalIntParameters) { if (parItem.Value is string) { IFCPropertySet.AddParameterString(doc, element, category, this, parItem.Key, (string)parItem.Value, Id); } else if (parItem.Value is double) { IFCPropertySet.AddParameterDouble(doc, element, category, this, parItem.Key, SpecTypeId.Custom, UnitTypeId.General, (double)parItem.Value, Id); } else if (parItem.Value is int) { IFCPropertySet.AddParameterInt(doc, element, category, this, parItem.Key, (int)parItem.Value, Id); } else if (parItem.Value is bool) { IFCPropertySet.AddParameterBoolean(doc, element, category, this, parItem.Key, (bool)parItem.Value, Id); } } } } }
/// <summary> /// Create geometry for a particular representation item, and add to scope. /// </summary> /// <param name="shapeEditScope">The geometry creation scope.</param> /// <param name="lcs">Local coordinate system for the geometry, without scale.</param> /// <param name="scaledLcs">Local coordinate system for the geometry, including scale, potentially non-uniform.</param> /// <param name="guid">The guid of an element for which represntation is being created.</param> protected override void CreateShapeInternal(IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid) { base.CreateShapeInternal(shapeEditScope, lcs, scaledLcs, guid); IFCRepresentation parentRep = shapeEditScope.ContainingRepresentation; IList <Curve> transformedCurves = new List <Curve>(); if (Curve != null) { Curve transformedCurve = CreateTransformedCurve(Curve, parentRep, lcs); if (transformedCurve != null) { transformedCurves.Add(transformedCurve); } } else if (CurveLoop != null) { foreach (Curve curve in CurveLoop) { Curve transformedCurve = CreateTransformedCurve(curve, parentRep, lcs); if (transformedCurve != null) { transformedCurves.Add(transformedCurve); } } } // TODO: set graphics style for footprint curves. IFCRepresentationIdentifier repId = (parentRep == null) ? IFCRepresentationIdentifier.Unhandled : parentRep.Identifier; bool createModelGeometry = (repId == IFCRepresentationIdentifier.Body) || (repId == IFCRepresentationIdentifier.Axis) || (repId == IFCRepresentationIdentifier.Unhandled); ElementId gstyleId = ElementId.InvalidElementId; if (createModelGeometry) { Category curveCategory = IFCCategoryUtil.GetSubCategoryForRepresentation(shapeEditScope.Document, Id, parentRep.Identifier); if (curveCategory != null) { GraphicsStyle graphicsStyle = curveCategory.GetGraphicsStyle(GraphicsStyleType.Projection); if (graphicsStyle != null) { gstyleId = graphicsStyle.Id; } } } foreach (Curve curve in transformedCurves) { if (createModelGeometry) { curve.SetGraphicsStyleId(gstyleId); shapeEditScope.AddGeometry(IFCSolidInfo.Create(Id, curve)); } else { // Default: assume a plan view curve. shapeEditScope.AddFootprintCurve(curve); } } }
protected virtual void CreateParametersInternal(Document doc, Element element) { if (element != null) { Category category = IFCPropertySet.GetCategoryForParameterIfValid(element, Id); // Set the element name. SetName(doc, element, category); // Set the element description. SetDescription(doc, element, category); // The list of materials. SetMaterialParameter(doc, element, category); // Set the "IfcSystem" parameter. SetSystemParameter(doc, element, category); // Set the element GUID. bool elementIsType = (element is ElementType); BuiltInParameter ifcGUIDId = GetGUIDParameter(element, elementIsType); Parameter guidParam = element.get_Parameter(ifcGUIDId); if (guidParam != null) { if (!guidParam.IsReadOnly) { guidParam.Set(GlobalId); } } else { ExporterIFCUtils.AddValueString(element, new ElementId(ifcGUIDId), GlobalId); } // Set the "IfcExportAs" parameter. string ifcExportAs = IFCCategoryUtil.GetCustomCategoryName(this); if (!string.IsNullOrWhiteSpace(ifcExportAs)) { IFCPropertySet.AddParameterString(doc, element, category, this, IFCSharedParameters.IfcExportAs, ifcExportAs, Id); } // Set the IFCElementAssembly Parameter if (Decomposes != null) { string containerParamName = (Decomposes is IFCElementAssembly) ? "IfcElementAssembly" : "IfcDecomposes"; string containerParamGUIDName = (Decomposes is IFCElementAssembly) ? "IfcElementAssemblyGUID" : "IfcDecomposesGUID"; IFCPropertySet.AddParameterString(doc, element, category, containerParamName, Decomposes.Name, Id); IFCPropertySet.AddParameterString(doc, element, category, containerParamGUIDName, Decomposes.GlobalId, Id); } // Set additional parameters (if any), e.g. for Classification assignments if (AdditionalIntParameters.Count > 0) { foreach (KeyValuePair <string, object> parItem in AdditionalIntParameters) { if (parItem.Value is string) { IFCPropertySet.AddParameterString(doc, element, category, parItem.Key, (string)parItem.Value, Id); } else if (parItem.Value is double) { IFCPropertySet.AddParameterDouble(doc, element, category, parItem.Key, SpecTypeId.Custom, (double)parItem.Value, Id); } else if (parItem.Value is int) { IFCPropertySet.AddParameterInt(doc, element, category, parItem.Key, (int)parItem.Value, Id); } else if (parItem.Value is bool) { IFCPropertySet.AddParameterBoolean(doc, element, category, parItem.Key, (bool)parItem.Value, Id); } } } } }
public void ImportIFC(ImporterIFC importer) { TheImporter = this; IDictionary <String, String> options = importer.GetOptions(); TheOptions = m_ImportOptions = IFCImportOptions.Create(options); // An early check, based on the options set - if we are allowed to use an up-to-date existing file on disk, use it. try { string revitFileName = IFCImportFile.GetRevitFileName(importer.FullFileName); if (!TheOptions.ForceImport && !NeedsReload(importer.FullFileName, revitFileName)) { return; } // Clear the category mapping table, to force reload of options. IFCCategoryUtil.Clear(); if (TheOptions.Intent != IFCImportIntent.Reference) { IFCImportFile.Import(importer); } else { Document originalDocument = importer.Document; Document ifcDocument = null; if (TheOptions.Action == IFCImportAction.Link) { string linkedFileName = IFCImportFile.GetRevitFileName(importer.FullFileName); ifcDocument = LoadOrCreateLinkDocument(originalDocument, linkedFileName); if (ifcDocument == null) { return; } } else { ifcDocument = originalDocument; } bool useCachedRevitFile = DocumentUpToDate(ifcDocument, importer.FullFileName); // In the case where the document is already opened as a link, but it has been updated on disk, // give the user a warning and use the cached value. if (!useCachedRevitFile && ifcDocument.IsLinked) { useCachedRevitFile = true; Importer.AddDelayedLinkError(BuiltInFailures.ImportFailures.IFCCantUpdateLinkedFile); } if (!useCachedRevitFile) { m_ImportCache = IFCImportCache.Create(ifcDocument, importer.FullFileName); // Limit creating the cache to Link, but may either remove limiting or make it more restrict (reload only) later. if (TheOptions.Action == IFCImportAction.Link) { TheCache.CreateExistingElementMaps(ifcDocument); } // TheFile will contain the same value as the return value for this function. IFCImportFile.Create(importer.FullFileName, m_ImportOptions, ifcDocument); } if (useCachedRevitFile || IFCImportFile.TheFile != null) { if (IFCImportFile.TheFile != null) { if (IFCImportFile.TheFile.IFCProject != null) { IFCObjectDefinition.CreateElement(ifcDocument, IFCImportFile.TheFile.IFCProject); } IFCImportFile.TheFile.EndImport(ifcDocument, importer.FullFileName); } if (TheOptions.Action == IFCImportAction.Link) { // If we have an original Revit link file name, don't create a new RvtLinkSymbol - // we will use the existing one. bool useExistingType = (TheOptions.RevitLinkFileName != null); IFCImportFile.LinkInFile(importer.FullFileName, ifcDocument, originalDocument, useExistingType, !useCachedRevitFile); } } m_ImportCache.Reset(ifcDocument); } } catch (Exception ex) { if (IFCImportFile.TheFile != null) { IFCImportFile.TheFile.Log.LogError(-1, ex.Message, false); } } finally { if (IFCImportFile.TheFile != null) { IFCImportFile.TheFile.Close(); } } }