/// <summary> /// Exports an element as a zone. /// </summary> /// <param name="exporterIFC">The ExporterIFC object.</param> /// <param name="element">The element.</param> /// <param name="productWrapper">The ProductWrapper.</param> public static void ExportZone(ExporterIFC exporterIFC, Zone element, ProductWrapper productWrapper) { if (element == null) { return; } // Check the intended IFC entity or type name is in the exclude list specified in the UI Common.Enums.IFCEntityType elementClassTypeEnum = Common.Enums.IFCEntityType.IfcZone; if (ExporterCacheManager.ExportOptionsCache.IsElementInExcludeList(elementClassTypeEnum)) { return; } HashSet <IFCAnyHandle> spaceHnds = new HashSet <IFCAnyHandle>(); SpaceSet spaces = element.Spaces; foreach (Space space in spaces) { if (space == null) { continue; } IFCAnyHandle spaceHnd = ExporterCacheManager.SpaceInfoCache.FindSpaceHandle(space.Id); if (!IFCAnyHandleUtil.IsNullOrHasNoValue(spaceHnd)) { spaceHnds.Add(spaceHnd); } } if (spaceHnds.Count == 0) { return; } IFCFile file = exporterIFC.GetFile(); using (IFCTransaction tr = new IFCTransaction(file)) { string guid = GUIDUtil.CreateGUID(element); IFCAnyHandle ownerHistory = ExporterCacheManager.OwnerHistoryHandle; string name = NamingUtil.GetNameOverride(element, NamingUtil.GetIFCName(element)); string description = NamingUtil.GetDescriptionOverride(element, null); string objectType = NamingUtil.GetObjectTypeOverride(element, NamingUtil.GetFamilyAndTypeName(element)); string longName = NamingUtil.GetLongNameOverride(element, null); IFCAnyHandle zoneHnd = IFCInstanceExporter.CreateZone(file, guid, ownerHistory, name, description, objectType, longName); productWrapper.AddElement(element, zoneHnd); string relAssignsGuid = GUIDUtil.CreateSubElementGUID(element, (int)IFCZoneSubElements.RelAssignsToGroup); IFCInstanceExporter.CreateRelAssignsToGroup(file, relAssignsGuid, ownerHistory, null, null, spaceHnds, null, zoneHnd); tr.Commit(); return; } }
/// <summary> /// When the removeSpace Button is clicked, the selected spaces will be removed from the /// current Zone element. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void removeSpaceButton_Click(object sender, EventArgs e) { SpaceSet set = new SpaceSet(); foreach (SpaceItem item in this.currentSpacesListView.SelectedItems) { set.Insert(item.Space); } m_zone.RemoveSpaces(set); UpdateSpaceList(); }
/// <summary> /// When the addSpace Button is clicked, the selected spaces will be added to the /// current Zone element. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void addSpaceButton_Click(object sender, EventArgs e) { SpaceSet set = new SpaceSet(); foreach (SpaceItem item in this.availableSpacesListView.SelectedItems) { set.Insert(item.Space); } m_zone.AddSpaces(set); UpdateSpaceList(); }
/// <summary> /// Exports an element as a zone. /// </summary> /// <param name="exporterIFC">The ExporterIFC object.</param> /// <param name="element">The element.</param> /// <param name="productWrapper">The ProductWrapper.</param> public static void ExportZone(ExporterIFC exporterIFC, Zone element, ProductWrapper productWrapper) { if (element == null) { return; } HashSet <IFCAnyHandle> spaceHnds = new HashSet <IFCAnyHandle>(); SpaceSet spaces = element.Spaces; foreach (Space space in spaces) { if (space == null) { continue; } IFCAnyHandle spaceHnd = ExporterCacheManager.SpaceInfoCache.FindSpaceHandle(space.Id); if (!IFCAnyHandleUtil.IsNullOrHasNoValue(spaceHnd)) { spaceHnds.Add(spaceHnd); } } if (spaceHnds.Count == 0) { return; } IFCFile file = exporterIFC.GetFile(); using (IFCTransaction tr = new IFCTransaction(file)) { string guid = GUIDUtil.CreateGUID(element); IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle(); string name = NamingUtil.GetNameOverride(element, NamingUtil.GetIFCName(element)); string description = NamingUtil.GetDescriptionOverride(element, null); string objectType = NamingUtil.GetObjectTypeOverride(element, exporterIFC.GetFamilyName()); IFCAnyHandle zoneHnd = IFCInstanceExporter.CreateZone(file, guid, ownerHistory, name, description, objectType); productWrapper.AddElement(element, zoneHnd); string relAssignsGuid = GUIDUtil.CreateSubElementGUID(element, (int)IFCZoneSubElements.RelAssignsToGroup); IFCInstanceExporter.CreateRelAssignsToGroup(file, relAssignsGuid, ownerHistory, null, null, spaceHnds, null, zoneHnd); tr.Commit(); return; } }
/// <summary> /// Remove some spaces to current Zone. /// </summary> /// <param name="spaces"></param> public void RemoveSpaces(SpaceSet spaces) { m_currentZone.RemoveSpaces(spaces); }
/// <summary> /// Add some spaces to current Zone. /// </summary> /// <param name="spaces"></param> public void AddSpaces(SpaceSet spaces) { m_currentZone.AddSpaces(spaces); }