Ejemplo n.º 1
0
        /// <summary>
        /// Create a new log from a file name.
        /// </summary>
        /// <param name="logFileName">The file name.</param>
        static public IFCImportLog CreateLog(string logFileName, string extension)
        {
            IFCImportLog importLog = new IFCImportLog();

            if (!CreateLogInternal(importLog, logFileName + "." + extension))
            {
                // Try a unique file name in case the original file is locked for some reason.
                CreateLogInternal(importLog, logFileName + "." + Guid.NewGuid().ToString() + "." + extension);
            }

            return(importLog);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a new log from a file name.
        /// </summary>
        /// <param name="logFileName">The file name.</param>
        static public IFCImportLog CreateLog(string logFileName)
        {
            IFCImportLog importLog = new IFCImportLog();

            try
            {
                importLog.OpenLog(logFileName);
                importLog.WriteLine("<A NAME=\"Warnings and Errors\"></A>Warnings and Errors");
                importLog.WriteLine("");
            }
            catch
            {
                // TODO: potentially alert user if log file can't be created.
            }
            return(importLog);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create a new log from a file name.
        /// </summary>
        /// <param name="logFileName">The file name.</param>
        static public IFCImportLog CreateLog(string logFileName, string extension, bool createLogFile)
        {
            IFCImportLog importLog = new IFCImportLog();

            // If we are maximizing performance, don't create a log file.
            if (!createLogFile)
            {
                return(importLog);
            }

            if (!CreateLogInternal(importLog, logFileName + "." + extension))
            {
                // Try a unique file name in case the original file is locked for some reason.
                CreateLogInternal(importLog, logFileName + "." + Guid.NewGuid().ToString() + "." + extension);
            }

            return(importLog);
        }
Ejemplo n.º 4
0
        static private bool CreateLogInternal(IFCImportLog importLog, string logFileName)
        {
            try
            {
                importLog.OpenLog(logFileName);
            }
            catch
            {
                return(false);
            }

            if (importLog.LoggingEnabled)
            {
                importLog.WriteLine("<A NAME=\"Warnings and Errors\"></A>Warnings and Errors");
                importLog.WriteLine("");
                return(true);
            }

            return(false);
        }
Ejemplo n.º 5
0
      /// <summary>
      /// Create a new log from a file name.
      /// </summary>
      /// <param name="logFileName">The file name.</param>
      static public IFCImportLog CreateLog(string logFileName, string extension)
      {
         IFCImportLog importLog = new IFCImportLog();

         if (!CreateLogInternal(importLog, logFileName + "." + extension))
         {
            // Try a unique file name in case the original file is locked for some reason.
            CreateLogInternal(importLog, logFileName + "." + Guid.NewGuid().ToString() + "." + extension);
         }

         return importLog;
      }
Ejemplo n.º 6
0
      static private bool CreateLogInternal(IFCImportLog importLog, string logFileName)
      {
         try
         {
            importLog.OpenLog(logFileName);
         }
         catch
         {
            return false;
         }

         if (importLog.LoggingEnabled)
         {
            importLog.WriteLine("<A NAME=\"Warnings and Errors\"></A>Warnings and Errors");
            importLog.WriteLine("");
            return true;
         }

         return false;
      }
Ejemplo n.º 7
0
      /// <summary>
      /// Import an IFC file into a given document for Reference only.
      /// </summary>
      /// <param name="document">The host document for the import.</param>
      /// <param name="fullFileName">The full file name of the document.</param>
      /// <param name="options">The list of configurable options for this import.</param>
      public void ReferenceIFC(Document document, string fullFileName, IDictionary<String, String> 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.
         m_ImportLog = IFCImportLog.CreateLog(fullFileName, "log.html");

         Document originalDocument = document;
         Document ifcDocument = null;

         if (TheOptions.Action == IFCImportAction.Link)
         {
            string linkedFileName = IFCImportFile.GetRevitFileName(fullFileName);

            ifcDocument = LoadOrCreateLinkDocument(originalDocument, linkedFileName);
            if (ifcDocument == null)
               return;
         }
         else
            ifcDocument = originalDocument;

         bool useCachedRevitFile = DocumentUpToDate(ifcDocument, 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, 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(fullFileName, m_ImportOptions, ifcDocument);
         }

         if (useCachedRevitFile || IFCImportFile.TheFile != null)
         {
            IFCImportFile theFile = IFCImportFile.TheFile;
            if (theFile != null)
            {
               if (theFile.IFCProject != null)
                  IFCObjectDefinition.CreateElement(ifcDocument, theFile.IFCProject);

               // Also process any other entities to create.
               foreach (IFCObjectDefinition objDef in IFCImportFile.TheFile.OtherEntitiesToCreate)
                  IFCObjectDefinition.CreateElement(ifcDocument, objDef);

               theFile.EndImport(ifcDocument, fullFileName);
            }

            if (TheOptions.Action == IFCImportAction.Link)
            {
               // If we have an original Revit link file name, don't create a new RevitLinkType - 
               // we will use the existing one.
               bool useExistingType = (TheOptions.RevitLinkFileName != null);
               ElementId revitLinkTypeId = IFCImportFile.LinkInFile(fullFileName, ifcDocument, originalDocument, useExistingType, !useCachedRevitFile);
            }
         }

         if (m_ImportCache != null)
            m_ImportCache.Reset(ifcDocument);
      }
Ejemplo n.º 8
0
 /// <summary>
 /// Create a new log from a file name.
 /// </summary>
 /// <param name="logFileName">The file name.</param>
 static public IFCImportLog CreateLog(string logFileName)
 {
     IFCImportLog importLog = new IFCImportLog();
     try
     {
         importLog.OpenLog(logFileName);
         importLog.WriteLine("<A NAME=\"Warnings and Errors\"></A>Warnings and Errors");
         importLog.WriteLine("");
     }
     catch
     {
         // TODO: potentially alert user if log file can't be created.
     }
     return importLog;
 }