Example #1
0
        /// <summary>
        /// Do a Parametric import operation.
        /// </summary>
        /// <param name="importer">The internal ImporterIFC class that contains necessary information for the import.</param>
        /// <remarks>This is a thin wrapper to the native code that still handles Open IFC.  This should be eventually obsoleted.</remarks>
        public static void Import(ImporterIFC importer)
        {
            IFCFile ifcFile = null;

            try
            {
                IFCSchemaVersion schemaVersion = IFCSchemaVersion.IFC2x3;
                ifcFile = CreateIFCFile(importer.FullFileName, out schemaVersion);

                IFCFileReadOptions readOptions = new IFCFileReadOptions();
                readOptions.FileName          = importer.FullFileName;
                readOptions.XMLConfigFileName = Path.Combine(DirectoryUtil.RevitProgramPath, "EDM\\ifcXMLconfiguration.xml");

                ifcFile.Read(readOptions);
                importer.SetFile(ifcFile);

                //If there is more than one project, we will be ignoring all but the first one.
                IList <IFCAnyHandle> projects = ifcFile.GetInstances(IFCAnyHandleUtil.GetIFCEntityTypeName(IFCEntityType.IfcProject), false);
                if (projects.Count == 0)
                {
                    throw new InvalidOperationException("Failed to import IFC to Revit.");
                }

                IFCAnyHandle project = projects[0];

                importer.ProcessIFCProject(project);

                StoreIFCCreatorInfo(ifcFile, importer.Document.ProjectInformation);
            }
            finally
            {
                if (ifcFile != null)
                {
                    ifcFile.Close();
                    ifcFile = null;
                }
            }
        }
Example #2
0
        //should be removed when all handles are processed in .NET
        public static void Import(ImporterIFC importer)
        {
            IFCFile ifcFile = null;

            try
            {
                IFCSchemaVersion schemaVersion = IFCSchemaVersion.IFC2x3;
                ifcFile = CreateIFCFile(importer.FullFileName, out schemaVersion);
                
                IFCFileReadOptions readOptions = new IFCFileReadOptions();
                readOptions.FileName = importer.FullFileName;
                readOptions.XMLConfigFileName = Path.Combine(RevitProgramPath, "EDM\\ifcXMLconfiguration.xml");

                ifcFile.Read(readOptions);
                importer.SetFile(ifcFile);

                //If there is more than one project, we will be ignoring all but the first one.
                IList<IFCAnyHandle> projects = ifcFile.GetInstances(IFCAnyHandleUtil.GetIFCEntityTypeName(IFCEntityType.IfcProject), false);
                if (projects.Count == 0)
                    throw new InvalidOperationException("Failed to import IFC to Revit.");

                IFCAnyHandle project = projects[0];
                
                importer.ProcessIFCProject(project);
            }
            finally
            {
                if (ifcFile != null)
                {
                    ifcFile.Close();
                    ifcFile = null;
                }
            }
        }