protected override IfcPersonAndOrganization Mapping(Contact contact, IfcPersonAndOrganization ifcPersonAndOrganization) { IfcPerson ifcPerson = Exchanger.TargetRepository.Instances.New <IfcPerson>(); IfcOrganization ifcOrganization = Exchanger.TargetRepository.Instances.New <IfcOrganization>(); //add Organization code if (Exchanger.StringHasValue(contact.OrganizationCode)) { ifcOrganization.Id = contact.OrganizationCode; } if (Exchanger.StringHasValue(contact.Company)) { ifcOrganization.Name = contact.Company; } //add GivenName if (Exchanger.StringHasValue(contact.GivenName)) { ifcPerson.GivenName = contact.GivenName; } //add Family Name if (Exchanger.StringHasValue(contact.FamilyName)) { ifcPerson.FamilyName = contact.FamilyName; } if (contact.Categories != null && contact.Categories.Any()) { SetRoles(contact, ifcPerson); } //add addresses into IfcPerson object //add Telecom Address IfcTelecomAddress ifcTelecomAddress = SetTelecomAddress(contact); ifcPerson.Addresses.Add(ifcTelecomAddress);//add to existing collection // Add postal address IfcPostalAddress ifcPostalAddress = SetAddress(contact); ifcPerson.Addresses.Add(ifcPostalAddress);//add to existing collection //add the person and the organization objects ifcPersonAndOrganization.ThePerson = ifcPerson; ifcPersonAndOrganization.TheOrganization = ifcOrganization; return(ifcPersonAndOrganization); }
private IfcTelecomAddress SetTelecomAddress(Contact contact) { IfcTelecomAddress ifcTelecomAddress = Exchanger.TargetRepository.Instances.New <IfcTelecomAddress>(); //add email if (Exchanger.StringHasValue(contact.Email)) { ifcTelecomAddress.ElectronicMailAddresses.Add(contact.Email); //add to existing collection } //add Phone if (Exchanger.StringHasValue(contact.Phone)) { ifcTelecomAddress.TelephoneNumbers.Add(contact.Phone);//add to existing collection } return(ifcTelecomAddress); }
public static string GetAsString(this IfcAddress ifcAddress) { StringBuilder address = new StringBuilder(); if (ifcAddress is IfcPostalAddress) { IfcPostalAddress ifcPostalAddress = (ifcAddress as IfcPostalAddress); if (ifcPostalAddress.PostalBox.HasValue) { address.Append(ifcPostalAddress.PostalBox); address.Append(", "); } if (ifcPostalAddress.InternalLocation.HasValue) { address.Append(ifcPostalAddress.InternalLocation); address.Append(", "); } if (ifcPostalAddress.AddressLines != null) { foreach (var item in ifcPostalAddress.AddressLines) { address.Append(item); address.Append(", "); } } if (ifcPostalAddress.Town.HasValue) { address.Append(ifcPostalAddress.Town); address.Append(", "); } if (ifcPostalAddress.Region.HasValue) { address.Append(ifcPostalAddress.Region); address.Append(", "); } if (ifcPostalAddress.PostalCode.HasValue) { address.Append(ifcPostalAddress.PostalCode); address.Append(", "); } if (ifcPostalAddress.Country.HasValue) { address.Append(ifcPostalAddress.Country); } } if (ifcAddress is IfcTelecomAddress) { IfcTelecomAddress ifcTelecomAddress = (ifcAddress as IfcTelecomAddress); if (ifcTelecomAddress.TelephoneNumbers != null) { foreach (var item in ifcTelecomAddress.TelephoneNumbers) { address.Append(item); address.Append(", "); } } if (ifcTelecomAddress.FacsimileNumbers != null) { foreach (var item in ifcTelecomAddress.FacsimileNumbers) { address.Append("FAX:"); address.Append(item); address.Append(", "); } } if (ifcTelecomAddress.ElectronicMailAddresses != null) { foreach (var item in ifcTelecomAddress.ElectronicMailAddresses) { address.Append("EMAIL:"); address.Append(item); address.Append(", "); } } if (ifcTelecomAddress.WWWHomePageURL.HasValue) { address.Append("WEB:"); address.Append(ifcTelecomAddress.WWWHomePageURL); } } return(address.ToString()); }
public void CreatePersonAndOrganization(COBieContactRow row, IfcPersonAndOrganization ifcPersonAndOrganization = null) { if (!Contacts.ContainsKey(row.Email)) //should filter on merge also unless Contacts is reset { IfcPerson ifcPerson = Model.Instances.New <IfcPerson>(); IfcOrganization ifcOrganization = Model.Instances.New <IfcOrganization>(); if (ifcPersonAndOrganization == null) { ifcPersonAndOrganization = Model.Instances.New <IfcPersonAndOrganization>(); } Contacts.Add(row.Email, ifcPersonAndOrganization); //build a list to reference for History objects //add email IfcTelecomAddress ifcTelecomAddress = Model.Instances.New <IfcTelecomAddress>(); if (ValidateString(row.Email)) { if (ifcTelecomAddress.ElectronicMailAddresses == null) { ifcTelecomAddress.SetElectronicMailAddress(row.Email); //create the LabelCollection and set to ElectronicMailAddresses field } else { ifcTelecomAddress.ElectronicMailAddresses.Add(row.Email); //add to existing collection } } //IfcPersonAndOrganization has no OwnerHistory so our COBie is extracting this from IfcProject so do nothing here //add Role from Category if (ValidateString(row.Category)) { IfcActorRole ifcActorRole = Model.Instances.New <IfcActorRole>(); ifcActorRole.RoleString = row.Category; if (ifcPerson.Roles == null) { ifcPerson.SetRoles(ifcActorRole);//create the ActorRoleCollection and set to Roles field } else { ifcPerson.Roles.Add(ifcActorRole);//add to existing collection } } //add Company if (ValidateString(row.Company)) { ifcOrganization.Name = row.Company; } else { ifcOrganization.Name = "Unknown"; //is not an optional field so fill with unknown value } //add Phone if (ValidateString(row.Phone)) { if (ifcTelecomAddress.TelephoneNumbers == null) { ifcTelecomAddress.SetTelephoneNumbers(row.Phone);//create the LabelCollection and set to TelephoneNumbers field } else { ifcTelecomAddress.TelephoneNumbers.Add(row.Phone);//add to existing collection } } //External System, as no history object we have to allow this to default to DEFAUL_STRING, so do nothing here //External Object is retrieved from object type IfcPersonAndOrganization so do nothing here //add External Identifier if (ValidateString(row.ExtIdentifier)) { ifcPerson.Id = row.ExtIdentifier; } //add Department IfcPostalAddress ifcPostalAddress = Model.Instances.New <IfcPostalAddress>(); if (ValidateString(row.Department)) { ifcPostalAddress.InternalLocation = row.Department; } //add Organization code if (ValidateString(row.OrganizationCode)) { ifcOrganization.Id = row.OrganizationCode; } //add GivenName if (ValidateString(row.GivenName)) { ifcPerson.GivenName = row.GivenName; } //add Family Name if (ValidateString(row.FamilyName)) { ifcPerson.FamilyName = row.FamilyName; } //add Street if (ValidateString(row.Street)) { ifcPostalAddress.SetAddressLines(row.Street.Split(',')); } //add PostalBox if (ValidateString(row.PostalBox)) { ifcPostalAddress.PostalBox = row.PostalBox; } //add Town if (ValidateString(row.Town)) { ifcPostalAddress.Town = row.Town; } //add StateRegion if (ValidateString(row.StateRegion)) { ifcPostalAddress.Region = row.StateRegion; } //add PostalCode if (ValidateString(row.PostalCode)) { ifcPostalAddress.PostalCode = row.PostalCode; } //add Country if (ValidateString(row.Country)) { ifcPostalAddress.Country = row.Country; } //add addresses into IfcPerson object //add Telecom Address if (ifcPerson.Addresses == null) { ifcPerson.SetTelecomAddresss(ifcTelecomAddress);//create the AddressCollection and set to Addresses field } else { ifcPerson.Addresses.Add(ifcTelecomAddress);//add to existing collection } // Add postal address if (ifcPerson.Addresses == null) { ifcPerson.SetPostalAddresss(ifcPostalAddress);//create the AddressCollection and set to Addresses field } else { ifcPerson.Addresses.Add(ifcPostalAddress);//add to existing collection } //add the person and the organization objects ifcPersonAndOrganization.ThePerson = ifcPerson; ifcPersonAndOrganization.TheOrganization = ifcOrganization; } }
private static void CreateSimpleProperty(XbimModel model, IfcWallStandardCase wall, IfcOwnerHistory ifcOwnerHistory) { IfcPropertySingleValue ifcPropertySingleValue = model.Instances.New <IfcPropertySingleValue>(psv => { psv.Name = "IfcPropertySingleValue:Time"; psv.Description = ""; psv.NominalValue = new IfcTimeMeasure(150.0); psv.Unit = model.Instances.New <IfcSIUnit>(siu => { siu.UnitType = IfcUnitEnum.TIMEUNIT; siu.Name = IfcSIUnitName.SECOND; siu.Dimensions = model.Instances.New <IfcDimensionalExponents>(de => { de.LengthExponent = 0; de.MassExponent = 0; de.TimeExponent = 1; de.ElectricCurrentExponent = 0; de.ThermodynamicTemperatureExponent = 0; de.AmountOfSubstanceExponent = 0; de.LuminousIntensityExponent = 0; }); }); }); IfcPropertyEnumeratedValue ifcPropertyEnumeratedValue = model.Instances.New <IfcPropertyEnumeratedValue>(pev => { pev.Name = "IfcPropertyEnumeratedValue:Music"; pev.EnumerationReference = model.Instances.New <IfcPropertyEnumeration>(pe => { pe.Name = "Notes"; pe.EnumerationValues.Add(new IfcLabel("Do")); pe.EnumerationValues.Add(new IfcLabel("Re")); pe.EnumerationValues.Add(new IfcLabel("Mi")); pe.EnumerationValues.Add(new IfcLabel("Fa")); pe.EnumerationValues.Add(new IfcLabel("So")); pe.EnumerationValues.Add(new IfcLabel("La")); pe.EnumerationValues.Add(new IfcLabel("Ti")); }); pev.EnumerationValues.Add(new IfcLabel("Do")); pev.EnumerationValues.Add(new IfcLabel("Re")); pev.EnumerationValues.Add(new IfcLabel("Mi")); }); IfcPropertyBoundedValue ifcPropertyBoundedValue = model.Instances.New <IfcPropertyBoundedValue>(pbv => { pbv.Name = "IfcPropertyBoundedValue:Mass"; pbv.Description = ""; pbv.UpperBoundValue = new IfcMassMeasure(5000.0); pbv.LowerBoundValue = new IfcMassMeasure(1000.0); pbv.Unit = model.Instances.New <IfcSIUnit>(siu => { siu.UnitType = IfcUnitEnum.MASSUNIT; siu.Name = IfcSIUnitName.GRAM; siu.Prefix = IfcSIPrefix.KILO; siu.Dimensions = model.Instances.New <IfcDimensionalExponents>(de => { de.LengthExponent = 0; de.MassExponent = 1; de.TimeExponent = 0; de.ElectricCurrentExponent = 0; de.ThermodynamicTemperatureExponent = 0; de.AmountOfSubstanceExponent = 0; de.LuminousIntensityExponent = 0; }); }); }); List <IfcReal> definingValues = new List <IfcReal>() { new IfcReal(100.0), new IfcReal(200.0), new IfcReal(400.0), new IfcReal(800.0), new IfcReal(1600.0), new IfcReal(3200.0), }; List <IfcReal> definedValues = new List <IfcReal>() { new IfcReal(20.0), new IfcReal(42.0), new IfcReal(46.0), new IfcReal(56.0), new IfcReal(60.0), new IfcReal(65.0), }; IfcPropertyTableValue ifcPropertyTableValue = model.Instances.New <IfcPropertyTableValue>(ptv => { ptv.Name = "IfcPropertyTableValue:Sound"; foreach (var item in definingValues) { ptv.DefiningValues.Add(item); } foreach (var item in definedValues) { ptv.DefinedValues.Add(item); } ptv.DefinedUnit = model.Instances.New <IfcContextDependentUnit>(cd => { cd.Dimensions = model.Instances.New <IfcDimensionalExponents>(de => { de.LengthExponent = 0; de.MassExponent = 0; de.TimeExponent = 0; de.ElectricCurrentExponent = 0; de.ThermodynamicTemperatureExponent = 0; de.AmountOfSubstanceExponent = 0; de.LuminousIntensityExponent = 0; }); cd.UnitType = IfcUnitEnum.FREQUENCYUNIT; cd.Name = "dB"; }); }); List <IfcLabel> listValues = new List <IfcLabel>() { new IfcLabel("Red"), new IfcLabel("Green"), new IfcLabel("Blue"), new IfcLabel("Pink"), new IfcLabel("White"), new IfcLabel("Black"), }; IfcPropertyListValue ifcPropertyListValue = model.Instances.New <IfcPropertyListValue>(plv => { plv.Name = "IfcPropertyListValue:Colours"; foreach (var item in listValues) { plv.ListValues.Add(item); } }); IfcMaterial IfcMaterial = model.Instances.New <IfcMaterial>(m => { m.Name = "Brick"; }); IfcPropertyReferenceValue ifcPRValueMaterial = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:Material"; prv.PropertyReference = IfcMaterial; }); IfcPropertyReferenceValue ifcPRValuePerson = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:Person"; prv.PropertyReference = ifcOwnerHistory.OwningUser.ThePerson; }); IfcDateAndTime ifcDateAndTime = model.Instances.New <IfcDateAndTime>(dt => { dt.DateComponent = model.Instances.New <IfcCalendarDate>(cd => { cd.DayComponent = 25; cd.MonthComponent = 3; cd.YearComponent = 2013; }); dt.TimeComponent = model.Instances.New <IfcLocalTime>(lt => { lt.HourComponent = 10; lt.MinuteComponent = 30; lt.SecondComponent = 0; }); }); IfcPropertyReferenceValue ifcPRValueDateTime = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:DateAndTime"; prv.PropertyReference = ifcDateAndTime; }); IfcMaterialList ifcMaterialList = model.Instances.New <IfcMaterialList>(ml => { ml.Materials.Add(IfcMaterial); ml.Materials.Add(model.Instances.New <IfcMaterial>(m => { m.Name = "Cavity"; })); ml.Materials.Add(model.Instances.New <IfcMaterial>(m => { m.Name = "Block"; })); }); IfcPropertyReferenceValue ifcPRValueMatList = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:MaterialList"; prv.PropertyReference = ifcMaterialList; }); IfcPropertyReferenceValue ifcPRValueOrg = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:Organization"; prv.PropertyReference = ifcOwnerHistory.OwningUser.TheOrganization; }); IfcPropertyReferenceValue ifcPRValueDate = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:Date"; prv.PropertyReference = ifcDateAndTime.DateComponent; }); IfcPropertyReferenceValue ifcPRValueTime = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:Time"; prv.PropertyReference = ifcDateAndTime.TimeComponent; }); IfcPropertyReferenceValue ifcPRValuePersonOrg = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:PersonOrganization"; prv.PropertyReference = ifcOwnerHistory.OwningUser; }); IfcMaterialLayer ifcMaterialLayer = model.Instances.New <IfcMaterialLayer>(ml => { ml.Material = IfcMaterial; ml.LayerThickness = 100.0; }); IfcPropertyReferenceValue ifcPRValueMatLayer = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:MaterialLayer"; prv.PropertyReference = ifcMaterialLayer; }); IfcDocumentReference ifcDocumentReference = model.Instances.New <IfcDocumentReference>(dr => { dr.Name = "Document"; dr.Location = "c://Documents//TheDoc.Txt"; }); IfcPropertyReferenceValue ifcPRValueRef = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:Document"; prv.PropertyReference = ifcDocumentReference; }); IfcRegularTimeSeries ifcTimeSeries = model.Instances.New <IfcRegularTimeSeries>(ts => { ts.Name = "Regular Time Series"; ts.Description = "Time series of events"; ts.StartTime = model.Instances.New <IfcCalendarDate>(cd => { cd.DayComponent = 01; cd.MonthComponent = 1; cd.YearComponent = 2013; }); ts.EndTime = model.Instances.New <IfcCalendarDate>(cd => { cd.DayComponent = 01; cd.MonthComponent = 3; cd.YearComponent = 2013; }); ts.TimeSeriesDataType = IfcTimeSeriesDataTypeEnum.CONTINUOUS; ts.DataOrigin = IfcDataOriginEnum.MEASURED; ts.TimeStep = 604800; //7 days in secs }); IfcPropertyReferenceValue ifcPRValueTimeSeries = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:TimeSeries"; prv.PropertyReference = ifcTimeSeries; }); IfcPostalAddress ifcAddress = model.Instances.New <IfcPostalAddress>(a => { a.InternalLocation = "Room 101"; a.SetAddressLines(new string[] { "12 New road", "DoxField" }); a.Town = "Sunderland"; a.PostalCode = "DL01 6SX"; }); IfcPropertyReferenceValue ifcPRValueAddress = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:Address"; prv.PropertyReference = ifcAddress; }); IfcTelecomAddress IfcTelecomAddress = model.Instances.New <IfcTelecomAddress>(a => { a.SetTelephoneNumbers(new string[] { "01325 6589965" }); a.SetElectronicMailAddress(new string[] { "*****@*****.**" }); }); IfcPropertyReferenceValue ifcPRValueTelecom = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:Telecom"; prv.PropertyReference = IfcTelecomAddress; }); IfcCostValue ifcCostValue = model.Instances.New <IfcCostValue>(cv => { cv.Name = "Cost Value"; cv.Description = ""; cv.Value = new IfcMonetaryMeasure(155.0); cv.ApplicableDate = model.Instances.New <IfcCalendarDate>(cd => { cd.DayComponent = 02; cd.MonthComponent = 02; cd.YearComponent = 2013; }); cv.FixedUntilDate = model.Instances.New <IfcCalendarDate>(cd => { cd.DayComponent = 31; cd.MonthComponent = 12; cd.YearComponent = 2013; }); cv.CostType = "Annual rate of return"; cv.Condition = ""; }); IfcPropertyReferenceValue ifcPRValueCostValue = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:CostValue"; prv.PropertyReference = ifcCostValue; }); IfcEnvironmentalImpactValue IfcEnvironmentalImpactValue = model.Instances.New <IfcEnvironmentalImpactValue>(cv => { cv.Name = "Environmental Impact"; cv.Description = ""; cv.Value = model.Instances.New <IfcMeasureWithUnit>(mwu => { mwu.ValueComponent = new IfcReal(111.0); mwu.UnitComponent = model.Instances.New <IfcSIUnit>(siu => { siu.UnitType = IfcUnitEnum.LENGTHUNIT; siu.Name = IfcSIUnitName.METRE; siu.Dimensions = model.Instances.New <IfcDimensionalExponents>(de => { de.LengthExponent = 1; de.MassExponent = 0; de.TimeExponent = 0; de.ElectricCurrentExponent = 0; de.ThermodynamicTemperatureExponent = 0; de.AmountOfSubstanceExponent = 0; de.LuminousIntensityExponent = 0; }); }); }); cv.ApplicableDate = model.Instances.New <IfcCalendarDate>(cd => { cd.DayComponent = 02; cd.MonthComponent = 02; cd.YearComponent = 2013; }); cv.FixedUntilDate = model.Instances.New <IfcCalendarDate>(cd => { cd.DayComponent = 31; cd.MonthComponent = 12; cd.YearComponent = 2013; }); cv.ImpactType = "Embodied energy"; cv.Category = IfcEnvironmentalImpactCategoryEnum.MANUFACTURE; }); IfcPropertyReferenceValue ifcPRValueEnvironmentalImpact = model.Instances.New <IfcPropertyReferenceValue>(prv => { prv.Name = "IfcPropertyReferenceValue:EnvironmentalImpact"; prv.PropertyReference = IfcEnvironmentalImpactValue; }); //lets create the IfcElementQuantity IfcPropertySet ifcPropertySet = model.Instances.New <IfcPropertySet>(ps => { ps.OwnerHistory = ifcOwnerHistory; ps.Name = "Test:IfcPropertySet"; ps.Description = "Property Set"; ps.HasProperties.Add(ifcPropertySingleValue); ps.HasProperties.Add(ifcPropertyEnumeratedValue); ps.HasProperties.Add(ifcPropertyBoundedValue); ps.HasProperties.Add(ifcPropertyTableValue); ps.HasProperties.Add(ifcPropertyListValue); ps.HasProperties.Add(ifcPRValueMaterial); ps.HasProperties.Add(ifcPRValuePerson); ps.HasProperties.Add(ifcPRValueDateTime); ps.HasProperties.Add(ifcPRValueMatList); ps.HasProperties.Add(ifcPRValueOrg); ps.HasProperties.Add(ifcPRValueDate); ps.HasProperties.Add(ifcPRValueTime); ps.HasProperties.Add(ifcPRValuePersonOrg); ps.HasProperties.Add(ifcPRValueMatLayer); ps.HasProperties.Add(ifcPRValueRef); ps.HasProperties.Add(ifcPRValueTimeSeries); ps.HasProperties.Add(ifcPRValueAddress); ps.HasProperties.Add(ifcPRValueTelecom); ps.HasProperties.Add(ifcPRValueCostValue); ps.HasProperties.Add(ifcPRValueEnvironmentalImpact); }); //need to create the relationship IfcRelDefinesByProperties ifcRelDefinesByProperties = model.Instances.New <IfcRelDefinesByProperties>(rdbp => { rdbp.OwnerHistory = ifcOwnerHistory; rdbp.Name = "Property Association"; rdbp.Description = "IfcPropertySet associated to wall"; rdbp.RelatedObjects.Add(wall); rdbp.RelatingPropertyDefinition = ifcPropertySet; }); }