Example #1
0
        /// <summary>
        /// Processes IfcGroup handle.
        /// </summary>
        /// <param name="ifcGroup">The IfcGroup handle.</param>
        /// <returns>The IFCGroup object.</returns>
        public static IFCGroup ProcessIFCGroup(IFCAnyHandle ifcGroup)
        {
            if (IFCAnyHandleUtil.IsNullOrHasNoValue(ifcGroup))
            {
                Importer.TheLog.LogNullError(IFCEntityType.IfcGroup);
                return(null);
            }

            IFCEntity cachedIFCGroup;

            IFCImportFile.TheFile.EntityMap.TryGetValue(ifcGroup.StepId, out cachedIFCGroup);
            if (cachedIFCGroup != null)
            {
                return(cachedIFCGroup as IFCGroup);
            }

            if (IFCAnyHandleUtil.IsSubTypeOf(ifcGroup, IFCEntityType.IfcZone))
            {
                return(IFCZone.ProcessIFCZone(ifcGroup));
            }
            if (IFCAnyHandleUtil.IsSubTypeOf(ifcGroup, IFCEntityType.IfcSystem))
            {
                return(IFCSystem.ProcessIFCSystem(ifcGroup));
            }

            return(new IFCGroup(ifcGroup));
        }
        /// <summary>
        /// Finds contained systems.
        /// </summary>
        /// <param name="ifcRelHandle">The relation handle.</param>
        void ProcessIFCRelServicesBuildings(IFCAnyHandle ifcRelHandle)
        {
            IFCAnyHandle relatingSystem = IFCAnyHandleUtil.GetInstanceAttribute(ifcRelHandle, "RelatingSystem");

            if (IFCAnyHandleUtil.IsNullOrHasNoValue(relatingSystem))
            {
                Importer.TheLog.LogMissingRequiredAttributeError(ifcRelHandle, "RelatingSystem", false);
                return;
            }

            IFCSystem system = IFCSystem.ProcessIFCSystem(relatingSystem);

            if (system != null)
            {
                Systems.Add(system);
            }
        }
Example #3
0
        /// <summary>
        /// Top-level function that processes an IFC file for reference.
        /// </summary>
        /// <returns>True if the process is successful, false otherwise.</returns>
        private bool ProcessReference()
        {
            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)
            {
                Importer.TheLog.LogError(-1, "There were no IfcProjects found in the file.  Aborting import.", false);
                return(false);
            }

            IFCProject.ProcessIFCProject(projects[0]);

            // The IFC toolkit relies on the IFC schema definition to read in the file. The schema definition has entities that have data fields,
            // and INVERSE relationships. Unfortunately, the standard IFC 2x3 schema has a "bug" where one of the inverse relationships is missing.
            // Normally we don't care all that much, but now we do. So if we don't allow using this inverse (because if we did, it would just constantly
            // throw exceptions), we need another way to get the zones. This is the way.
            // We are also using this to find IfcSystems that don't have the optional IfcRelServicesBuildings set.
            if (!IFCImportFile.TheFile.Options.AllowUseHasAssignments)
            {
                IList <IFCAnyHandle> zones = IFCImportFile.TheFile.GetInstances(IFCEntityType.IfcZone, false);
                foreach (IFCAnyHandle zone in zones)
                {
                    IFCZone ifcZone = IFCZone.ProcessIFCZone(zone);
                    if (ifcZone != null)
                    {
                        OtherEntitiesToCreate.Add(ifcZone);
                    }
                }

                IList <IFCAnyHandle> systems = IFCImportFile.TheFile.GetInstances(IFCEntityType.IfcSystem, false);
                foreach (IFCAnyHandle system in systems)
                {
                    IFCSystem ifcSystem = IFCSystem.ProcessIFCSystem(system);
                    if (ifcSystem != null)
                    {
                        OtherEntitiesToCreate.Add(ifcSystem);
                    }
                }
            }

            return(PostProcessReference());
        }