private bool Process(string ifcFilePath, IFCImportOptions options, Document doc) { TheFileName = ifcFilePath; TheBrepCounter = 0; try { IFCSchemaVersion schemaVersion; m_IfcFile = CreateIFCFile(ifcFilePath, out schemaVersion); SchemaVersion = schemaVersion; } catch (Exception ex) { Importer.TheLog.LogError(-1, "There was an error reading the IFC file: " + ex.Message + ". Aborting import.", false); return(false); } Options = options; // The DirectShapeLibrary must be reset to potentially remove stale pointers from the last use. Document = doc; ShapeLibrary = DirectShapeLibrary.GetDirectShapeLibrary(doc); ShapeLibrary.Reset(); bool readFile = ProcessFile(ifcFilePath); if (!readFile) { return(false); } m_Transaction = new Transaction(doc); bool success = true; switch (options.Intent) { case IFCImportIntent.Reference: success = ProcessReference(); break; } if (success) { StoreIFCCreatorInfo(m_IfcFile, doc.ProjectInformation); } return(success); }
private bool Process(string ifcFilePath, IFCImportOptions options, Document doc) { // Manually set to false if necessary for debugging. CleanEntitiesAfterCreate = true; TheFileName = ifcFilePath; TheBrepCounter = 0; Log = IFCImportLog.CreateLog(ifcFilePath + ".log.html"); try { IFCSchemaVersion schemaVersion; m_IfcFile = CreateIFCFile(ifcFilePath, out schemaVersion); SchemaVersion = schemaVersion; } catch (Exception ex) { Log.LogError(-1, "There was an error reading the IFC file: " + ex.Message + ". Aborting import.", false); return(false); } Options = options; Document = doc; ShapeLibrary = DirectShapeLibrary.GetDirectShapeLibrary(doc); ShapeLibrary.Reset(); IFCFileReadOptions readOptions = new IFCFileReadOptions(); readOptions.FileName = ifcFilePath; readOptions.XMLConfigFileName = Path.Combine(RevitProgramPath, "EDM\\ifcXMLconfiguration.xml"); int numErrors = 0; int numWarnings = 0; try { Importer.TheCache.StatusBar.Set(String.Format(Resources.IFCReadingFile, TheFileName)); m_IfcFile.Read(readOptions, out numErrors, out numWarnings); } catch (Exception ex) { Log.LogError(-1, "There was an error reading the IFC file: " + ex.Message + ". Aborting import.", false); return(false); } if (numErrors > 0 || numWarnings > 0) { if (numErrors > 0) { if (numWarnings > 0) { Log.LogError(-1, "There were " + numErrors + " errors and " + numWarnings + " reading the IFC file. Please look at the log information at the end of this report for more information.", false); } else { Log.LogError(-1, "There were " + numErrors + " errors reading the IFC file. Please look at the log information at the end of this report for more information.", false); } } else { Log.LogWarning(-1, "There were " + numWarnings + " warnings reading the IFC file. Please look at the log information at the end of this report for more information.", false); } } m_Transaction = new Transaction(doc); switch (options.Intent) { case IFCImportIntent.Reference: InitializeOpenTransaction("Open IFC Reference File"); //If there is more than one project, we will be ignoring all but the first one. IList <IFCAnyHandle> projects = IFCImportFile.TheFile.GetInstances(IFCEntityType.IfcProject, false); if (projects.Count == 0) { Log.LogError(-1, "There were no IfcProjects found in the file. Aborting import.", false); return(false); } else { IFCProject.ProcessIFCProject(projects[0]); } break; } return(true); }