Exemple #1
0
        public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
        {
            switch (propIndex)
            {
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
                base.Parse(propIndex, value, nestedIndex);
                return;

            case 6:
                _relatingActor = (IfcActor)(value.EntityVal);
                return;

            case 7:
                _actingRole = (IfcActorRole)(value.EntityVal);
                return;

            default:
                throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper()));
            }
        }
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     switch (propIndex)
     {
         case 0:
         case 1:
         case 2:
         case 3:
         case 4:
         case 5:
             base.IfcParse(propIndex, value);
             break;
         case 6:
             _relatingActor = value.EntityVal as IfcActor;
             break;
         case 7:
             _actingRole = value.EntityVal as IfcActorRole;
             break;
         default:
             this.HandleUnexpectedAttribute(propIndex, value); break;
     }
 }
Exemple #3
0
 public IfcRelOccupiesSpaces(IfcGloballyUniqueId __GlobalId, IfcOwnerHistory __OwnerHistory, IfcLabel?__Name, IfcText?__Description, IfcObjectDefinition[] __RelatedObjects, IfcObjectTypeEnum?__RelatedObjectsType, IfcActor __RelatingActor, IfcActorRole __ActingRole)
     : base(__GlobalId, __OwnerHistory, __Name, __Description, __RelatedObjects, __RelatedObjectsType, __RelatingActor, __ActingRole)
 {
 }
        protected override IfcBuilding Mapping(Facility facility, IfcBuilding ifcBuilding)
        {
            #region Properties

            ifcBuilding.Name            = facility.Name;
            ifcBuilding.Description     = facility.Description;
            ifcBuilding.CompositionType = IfcElementCompositionEnum.ELEMENT;
            #endregion

            #region Default units

            Exchanger.DefaultLinearUnit   = new IfcUnitConverter(facility.LinearUnits.ToString());
            Exchanger.DefaultAreaUnit     = new IfcUnitConverter(facility.AreaUnits.ToString());
            Exchanger.DefaultVolumeUnit   = new IfcUnitConverter(facility.VolumeUnits.ToString());
            Exchanger.DefaultCurrencyUnit = facility.CurrencyUnit;

            #endregion

            #region Contacts
            if (facility.Contacts != null && facility.Contacts.Any())
            {
                var ContactMapping = Exchanger.GetOrCreateMappings <MappingContactToIfcPersonAndOrganization>();
                foreach (var contact in facility.Contacts)
                {
                    IfcPersonAndOrganization ifcPersonAndOrganization = ContactMapping.AddMapping(contact, ContactMapping.GetOrCreateTargetObject(contact.ExternalId));
                    //assign relationship
                    //create IfcActor to set CreatedBy and CreatedOn for next time ifc is imported as IfcActor is derived from IfcRoot
                    IfcActor actor = Exchanger.TargetRepository.Instances.New <IfcActor>();
                    Exchanger.SetUserHistory(actor, contact.ExternalSystem, (contact.CreatedBy == null) ? null : contact.CreatedBy.Email, (contact.CreatedOn == null) ? DateTime.Now : (DateTime)contact.CreatedOn);
                    using (OwnerHistoryEditScope context = new OwnerHistoryEditScope(Exchanger.TargetRepository, actor.OwnerHistory))
                    {
                        actor.TheActor = ifcPersonAndOrganization;
                    }
                    //assign the actor to the building
                    IfcRelAssignsToActor ifcRelAssignsToActor = Exchanger.TargetRepository.Instances.New <IfcRelAssignsToActor>();
                    Exchanger.SetUserHistory(ifcRelAssignsToActor, contact.ExternalSystem, (contact.CreatedBy == null) ? null : contact.CreatedBy.Email, (contact.CreatedOn == null) ? DateTime.Now : (DateTime)contact.CreatedOn);
                    using (OwnerHistoryEditScope context = new OwnerHistoryEditScope(Exchanger.TargetRepository, ifcRelAssignsToActor.OwnerHistory))
                    {
                        ifcRelAssignsToActor.RelatingActor = actor;
                        ifcRelAssignsToActor.RelatedObjects.Add(ifcBuilding);
                    }
                }
            }
            #endregion

            #region Categories
            if (facility.Categories != null)
            {
                foreach (var category in facility.Categories)
                {
                    Exchanger.ConvertCategoryToClassification(category, ifcBuilding);
                }
            }

            #endregion


            #region Project



            //COBie does nor require a project but Ifc does
            var ifcProject = Exchanger.TargetRepository.Instances.OfType <IfcProject>().FirstOrDefault();
            if (ifcProject == null)
            {
                ifcProject = Exchanger.TargetRepository.Instances.New <IfcProject>();
            }
            var projectMapping = Exchanger.GetOrCreateMappings <MappingProjectToIfcProject>();
            projectMapping.AddMapping(facility.Project, ifcProject);
            InitialiseUnits(ifcProject);
            #endregion

            #region Site
            //add the relationship between the site and the building if a site exists
            if (facility.Site != null)
            {
                var siteMapping = Exchanger.GetOrCreateMappings <MappingSiteToIfcSite>();
                var ifcSite     = siteMapping.AddMapping(facility.Site,
                                                         siteMapping.GetOrCreateTargetObject(facility.Site.ExternalId ?? Guid.NewGuid().ToString()));
                //add the relationship between the site and the project and the building
                ifcProject.AddSite(ifcSite);
                ifcSite.AddBuilding(ifcBuilding);
            }
            else //relate the building to the project
            {
                ifcProject.AddBuilding(ifcBuilding);
            }
            #endregion

            #region Floors
            //write out the floors if we have any
            if (facility.Floors != null)
            {
                var floorMapping = Exchanger.GetOrCreateMappings <MappingFloorToIfcBuildingStorey>();
                foreach (var floor in facility.Floors)
                {
                    var ifcFloor = floorMapping.AddMapping(floor, floorMapping.GetOrCreateTargetObject(floor.ExternalId));
                    ifcBuilding.AddToSpatialDecomposition(ifcFloor);
                }
            }
            #endregion


            #region AssetTypes
            //write out the floors if we have any
            if (facility.AssetTypes != null)
            {
                var assetTypeMapping = Exchanger.GetOrCreateMappings <MappingAssetTypeToIfcTypeObject>();
                foreach (var assetType in facility.AssetTypes.OrderBy(a => a.ExternalEntity))
                {
                    Exchanger.BeginAssetTypeInfoType();
                    assetTypeMapping.AddMapping(assetType, assetTypeMapping.GetOrCreateTargetObject(assetType.ExternalId));
                    Exchanger.EndAssetTypeInfoType();
                }
            }
            #endregion

            #region Attributes
            if (facility.Attributes != null)
            {
                foreach (var attribute in facility.Attributes)
                {
                    Exchanger.ConvertAttributeTypeToIfcObjectProperty(ifcBuilding, attribute);
                }
            }
            #endregion

            #region Zones

            if (facility.Zones != null)
            {
                var zoneTypeMapping = Exchanger.GetOrCreateMappings <MappingZoneToIfcZone>();
                foreach (var zone in facility.Zones)
                {
                    zoneTypeMapping.AddMapping(zone, zoneTypeMapping.GetOrCreateTargetObject(zone.ExternalId));
                }
            }

            #endregion

            #region Documents
            if (facility.Documents != null && facility.Documents.Any())
            {
                Exchanger.ConvertDocumentsToDocumentSelect(ifcBuilding, facility.Documents);
            }
            #endregion

            #region Add Space Geometry

            CreateSpaceProxies();

            #endregion

            return(ifcBuilding);
        }