Пример #1
0
        /// <summary>
        /// Add a space to the wrapper, with associated level and extrusion data information.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="handle">The element handle.</param>
        /// <param name="levelInfo">The level information.</param>
        /// <param name="data">The extrusion creation data (can be null.)</param>
        /// <param name="relateToLevel">Relate to the level in the setter, or not.</param>
        public void AddSpace(Element element, IFCAnyHandle handle, IFCLevelInfo levelInfo, IFCExtrusionCreationData data, bool relateToLevel, IFCExportInfoPair exportType)
        {
            bool actuallyRelateToLevel = relateToLevel && (levelInfo != null);

            InternalWrapper.AddSpace(handle, levelInfo, data, actuallyRelateToLevel);
            if (levelInfo == null && relateToLevel)
            {
                ExporterCacheManager.LevelInfoCache.OrphanedSpaces.Add(handle);
            }
            RegisterHandleWithElement(element, handle, exportType);
        }
Пример #2
0
        /// <summary>
        /// Add a generic element to the wrapper, with associated level and extrusion data information, and create associated internal property sets if option is set.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="handle">The element handle.</param>
        /// <param name="levelInfo">The level information.</param>
        /// <param name="data">The extrusion creation data (can be null.)</param>
        /// <param name="relateToLevel">Relate to the level in the setter, or not.</param>
        public void AddElement(Element element, IFCAnyHandle handle, IFCLevelInfo levelInfo, IFCExtrusionCreationData data, bool relateToLevel, IFCExportInfoPair exportType)
        {
            // There is a bug in the internal AddElement that requires us to do a levelInfo null check here.
            bool actuallyRelateToLevel = relateToLevel && (levelInfo != null);

            InternalWrapper.AddElement(handle, levelInfo, data, actuallyRelateToLevel);
            if (levelInfo == null && relateToLevel)
            {
                ExporterCacheManager.LevelInfoCache.OrphanedElements.Add(handle);
            }
            RegisterHandleWithElement(element, handle, exportType);
        }
Пример #3
0
        /// <summary>
        /// Gets an arbitrary handle from the wrapper, if one exists.
        /// </summary>
        /// <returns>The handle, or null if no handle exists.</returns>
        /// <remarks>Generally intended for when there is only one handle in the wrapper.</remarks>
        public IFCAnyHandle GetAnElement()
        {
            if (CreatedHandles.Count > 0)
            {
                foreach (IFCAnyHandle firstHandle in CreatedHandles)
                {
                    return(firstHandle);
                }
            }

            return(InternalWrapper.GetAnElement());
        }
Пример #4
0
 /// <summary>
 /// Clear propertyset assignments to the internal Handle stored in the wrapper if it is incomplete
 /// </summary>
 /// <param name="element">the element</param>
 public void ClearInternalHandleWrapperData(Element element)
 {
     if (InternalWrapper.Count > 0)
     {
         HashSet <IFCAnyHandle> propertySetToCreate = null;
         if (PropertySetsToCreate.TryGetValue(element, out propertySetToCreate))
         {
             ICollection <IFCAnyHandle> internalObjects = InternalWrapper.GetAllObjects();
             foreach (IFCAnyHandle internalObj in internalObjects)
             {
                 propertySetToCreate.Remove(internalObj);
             }
         }
     }
 }
Пример #5
0
        /// <summary>
        /// The Dispose function, to do bookkeeping at end of "using" block.
        /// </summary>
        public void Dispose()
        {
            // If we have a parent wrapper, postpone creating property set so that we
            // don't create the same property sets multiple times.
            if (ParentWrapper != null)
            {
                foreach (var propertySetToCreate in PropertySetsToCreate)
                {
                    if (!ParentWrapper.PropertySetsToCreate.TryGetValue(propertySetToCreate.Key,
                                                                        out HashSet <IFCAnyHandle> handles))
                    {
                        handles = new HashSet <IFCAnyHandle>();
                        ParentWrapper.PropertySetsToCreate.Add(propertySetToCreate.Key, handles);
                    }
                    handles.UnionWith(propertySetToCreate.Value);
                }

                ParentWrapper.CreatedHandles.UnionWith(CreatedHandles);

                foreach (var elementTypeHandle in ElementTypeHandles)
                {
                    if (ParentWrapper.ElementTypeHandles.ContainsKey(elementTypeHandle.Key))
                    {
                        continue;
                    }

                    ParentWrapper.ElementTypeHandles[elementTypeHandle.Key] = elementTypeHandle.Value;
                }
            }
            else
            {
                foreach (var propertySetToCreate in PropertySetsToCreate)
                {
                    PropertyUtil.CreateInternalRevitPropertySets(ExporterIFC, propertySetToCreate.Key, propertySetToCreate.Value);
                }

                foreach (var elementTypeHandle in ElementTypeHandles)
                {
                    PropertyUtil.CreateElementTypeProperties(ExporterIFC, elementTypeHandle.Key.Item1, elementTypeHandle.Value.Value, elementTypeHandle.Value.Key);
                }
            }

            InternalWrapper.Dispose();
        }
Пример #6
0
        /// <summary>
        /// Gets the first handle of a particular type, or null if none exists.
        /// </summary>
        /// <param name="type">The entity type.</param>
        /// <returns>The handle, or null.</returns>
        public IFCAnyHandle GetElementOfType(IFCEntityType type)
        {
            foreach (IFCAnyHandle handle in CreatedHandles)
            {
                if (IFCAnyHandleUtil.IsSubTypeOf(handle, type))
                {
                    return(handle);
                }
            }

            ICollection <IFCAnyHandle> internalObjects = InternalWrapper.GetAllObjects();

            foreach (IFCAnyHandle handle in internalObjects)
            {
                if (IFCAnyHandleUtil.IsSubTypeOf(handle, type))
                {
                    return(handle);
                }
            }

            return(null);
        }
Пример #7
0
        /// <summary>
        /// Get all handles in the wrapper.
        /// </summary>
        /// <returns>The collection of handles.</returns>
        public ISet <IFCAnyHandle> GetAllObjects()
        {
            ICollection <IFCAnyHandle> internalObjects = InternalWrapper.GetAllObjects();

            if (internalObjects.Count == 0)
            {
                return(CreatedHandles);
            }

            HashSet <IFCAnyHandle> allObjects = new HashSet <IFCAnyHandle>();

            // We aren't going to trust that the handles aren't stale.  This needs a rewrite
            // of disposal of entities, and in general a move to .NET only created entities.
            foreach (IFCAnyHandle internalObject in internalObjects)
            {
                if (!IFCAnyHandleUtil.IsNullOrHasNoValue(internalObject))
                {
                    allObjects.Add(internalObject);
                }
            }

            allObjects.UnionWith(CreatedHandles);
            return(allObjects);
        }
Пример #8
0
 /// <summary>
 /// Gets the extrusion creation data associated with a handle.
 /// </summary>
 /// <param name="handle">The handle.</param>
 /// <returns>The extrusion creation data, or null.</returns>
 public IFCExtrusionCreationData FindExtrusionCreationParameters(IFCAnyHandle handle)
 {
     return(InternalWrapper.FindExtrusionCreationParameters(handle));
 }
Пример #9
0
 /// <summary>
 /// Clear finish materials in this wrapper.
 /// </summary>
 public void ClearFinishMaterials()
 {
     InternalWrapper.ClearFinishMaterials();
 }
Пример #10
0
 /// <summary>
 /// Adds a material handle to associate with the IfcProduct in this wrapper.
 /// </summary>
 /// <param name="materialHnd"></param>
 public void AddFinishMaterial(IFCAnyHandle materialHnd)
 {
     InternalWrapper.AddFinishMaterial(materialHnd);
 }
Пример #11
0
 /// <summary>
 /// Adds a site (IfcObject) handle to associate with the IfcProduct in this wrapper.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="handle">The site handle.</param>
 public void AddSite(Element element, IFCAnyHandle handle)
 {
     RegisterHandleWithElement(element, handle);
     InternalWrapper.AddSite(handle);
 }
Пример #12
0
 /// <summary>
 /// Adds an annotation handle to associate with the IfcProduct in this wrapper.
 /// </summary>
 /// <param name="handle">The annotation handle.</param>
 /// <param name="levelInfo">The level information, can be null if relateToLevel is false.</param>
 /// <param name="relateToLevel">Whether the annotation is contained in a level.</param>
 public void AddAnnotation(IFCAnyHandle handle, IFCLevelInfo levelInfo, bool relateToLevel)
 {
     // The internal AddAnnotation takes an optional levelInfo, so we don't need to do a levelInfo null check here.
     InternalWrapper.AddAnnotation(handle, levelInfo, relateToLevel);
 }