public static void SetElementPhysicalSimpleQuantity(this IfcObject elem, string qSetName, string qualityName, double value, XbimQuantityTypeEnum quantityType, IfcNamedUnit unit) { IModel model = elem.ModelOf; IfcElementQuantity qset = GetElementQuantity(elem, qSetName); if (qset == null) { qset = model.Instances.New <IfcElementQuantity>(); qset.Name = qSetName; IfcRelDefinesByProperties relDef = model.Instances.New <IfcRelDefinesByProperties>(); relDef.RelatingPropertyDefinition = qset; relDef.RelatedObjects.Add(elem); } //remove existing simple quality IfcPhysicalSimpleQuantity simpleQuality = GetElementPhysicalSimpleQuantity(elem, qSetName, qualityName); if (simpleQuality != null) { IfcElementQuantity elementQuality = GetElementQuantity(elem, qSetName); elementQuality.Quantities.Remove(simpleQuality); model.Delete(simpleQuality); } switch (quantityType) { case XbimQuantityTypeEnum.AREA: simpleQuality = model.Instances.New <IfcQuantityArea>(sq => sq.AreaValue = (IfcAreaMeasure)value); break; case XbimQuantityTypeEnum.COUNT: simpleQuality = model.Instances.New <IfcQuantityCount>(sq => sq.CountValue = (IfcCountMeasure)value); break; case XbimQuantityTypeEnum.LENGTH: simpleQuality = model.Instances.New <IfcQuantityLength>(sq => sq.LengthValue = (IfcLengthMeasure)value); break; case XbimQuantityTypeEnum.TIME: simpleQuality = model.Instances.New <IfcQuantityTime>(sq => sq.TimeValue = (IfcTimeMeasure)value); break; case XbimQuantityTypeEnum.VOLUME: simpleQuality = model.Instances.New <IfcQuantityVolume>(sq => sq.VolumeValue = (IfcVolumeMeasure)value); break; case XbimQuantityTypeEnum.WEIGHT: simpleQuality = model.Instances.New <IfcQuantityWeight>(sq => sq.WeightValue = (IfcMassMeasure)value); break; default: return; } simpleQuality.Unit = unit; simpleQuality.Name = qualityName; qset.Quantities.Add(simpleQuality); }
/// <summary> /// Set the area measure to the building /// </summary> /// <param name="ifcBuilding">Building object</param> /// <param name="row">COBieFacilityRow object holding data</param> private void SetAreaMeasure(IfcBuilding ifcBuilding, COBieFacilityRow row) { IfcSIUnit ifcSIUnitArea = null; if (ValidateString(row.AreaUnits)) { ifcSIUnitArea = GetSIUnit(row.AreaUnits); } string areaMeasure = string.Empty; if (ValidateString(row.AreaMeasurement)) { areaMeasure = row.AreaMeasurement; } IfcQuantityArea IfcQuantityArea = Model.Instances.New <IfcQuantityArea>(qa => { qa.Unit = ifcSIUnitArea; qa.Name = "AreaMeasure"; qa.Description = "Created to maintain COBie information"; }); IfcElementQuantity ifcElementQuantity = Model.Instances.New <IfcElementQuantity>(eq => { eq.Quantities.Add(IfcQuantityArea); eq.MethodOfMeasurement = areaMeasure; eq.Description = "Created to maintain COBie information"; }); IfcRelDefinesByProperties ifcRelDefinesByProperties = Model.Instances.New <IfcRelDefinesByProperties>(rdbp => { rdbp.RelatedObjects.Add(ifcBuilding); rdbp.RelatingPropertyDefinition = ifcElementQuantity; rdbp.Description = "Created to maintain COBie information"; }); }
public static IfcPropertySingleValue SetPropertySingleValue(this Xbim.Ifc2x3.Kernel.IfcObject obj, string pSetName, string propertyName, IfcValue value) { IfcPropertySet pset = GetPropertySet(obj, pSetName); IModel model = null; if (pset == null) { model = obj.ModelOf; pset = model.Instances.New <IfcPropertySet>(); pset.Name = pSetName; IfcRelDefinesByProperties relDef = model.Instances.New <IfcRelDefinesByProperties>(); relDef.RelatingPropertyDefinition = pset; relDef.RelatedObjects.Add(obj); } //change existing property of the same name from the property set IfcPropertySingleValue singleVal = GetPropertySingleValue(obj, pSetName, propertyName); if (singleVal != null) { singleVal.NominalValue = value; } else { model = obj.ModelOf; singleVal = model.Instances.New <IfcPropertySingleValue>(psv => { psv.Name = propertyName; psv.NominalValue = value; }); pset.HasProperties.Add(singleVal); } return(singleVal); }
/// <summary> /// Adds an existing property set to the objecty, NB no check is done for duplicate psets /// </summary> /// <param name="obj"></param> /// <param name="pSet"></param> public static void AddPropertySet(this IfcObject obj, IfcPropertySet pSet) { IModel model = obj.ModelOf; IfcRelDefinesByProperties relDef = model.Instances.OfType <IfcRelDefinesByProperties>().Where(r => r.RelatingPropertyDefinition == pSet).FirstOrDefault();; if (relDef == null) { relDef = model.Instances.New <IfcRelDefinesByProperties>(); relDef.RelatingPropertyDefinition = pSet; } relDef.RelatedObjects.Add(obj); }
public static void SetPropertyTableItemValue(this Xbim.Ifc2x3.Kernel.IfcObject obj, string pSetName, string propertyTableName, IfcValue definingValue, IfcValue definedValue, IfcUnit definingUnit, IfcUnit definedUnit) { IfcPropertySet pset = GetPropertySet(obj, pSetName); IModel model = null; if (pset == null) { model = obj.ModelOf; pset = model.Instances.New <IfcPropertySet>(); pset.Name = pSetName; IfcRelDefinesByProperties relDef = model.Instances.New <IfcRelDefinesByProperties>(); relDef.RelatingPropertyDefinition = pset; relDef.RelatedObjects.Add(obj); } IfcPropertyTableValue table = GetPropertyTableValue(obj, pSetName, propertyTableName); if (table == null) { model = obj.ModelOf; table = model.Instances.New <IfcPropertyTableValue>(tb => { tb.Name = propertyTableName; }); pset.HasProperties.Add(table); table.DefinedUnit = definedUnit; table.DefiningUnit = definingUnit; } if (table.DefiningUnit != definingUnit || table.DefinedUnit != definedUnit) { throw new Exception("Inconsistent definition of the units in the property table."); } IfcValue itemValue = GetPropertyTableItemValue(obj, pSetName, propertyTableName, definingValue); if (itemValue != null) { itemValue = definedValue; } else { //if (table.DefiningValues == null) table.DefiningValues = new XbimList<IfcValue>(); table.DefiningValues.Add(definingValue); //if (table.DefinedValues == null) table.DefinedValues = new XbimList<IfcValue>(); table.DefinedValues.Add(definedValue); //check of integrity if (table.DefinedValues.Count != table.DefiningValues.Count) { throw new Exception("Inconsistent state of the property table. Number of defined and defining values are not the same."); } } }
/// <summary> /// Returns the propertyset of the specified name, null if it does not exist /// </summary> /// <param name="obj"></param> /// <param name="pSetName"></param> /// <returns></returns> public static IfcPropertySet GetPropertySet(this Xbim.Ifc2x3.Kernel.IfcObject obj, string pSetName, bool caseSensitive = true) { IfcRelDefinesByProperties rel = caseSensitive ? obj.IsDefinedByProperties.Where(r => r.RelatingPropertyDefinition.Name == pSetName).FirstOrDefault() : obj.IsDefinedByProperties.Where(r => r.RelatingPropertyDefinition.Name.ToString().ToLower() == pSetName.ToLower()).FirstOrDefault(); if (rel != null) { return(rel.RelatingPropertyDefinition as IfcPropertySet); } else { return(null); } }
public static IfcElementQuantity GetElementQuantity(this IfcObject elem, string pSetName, bool caseSensitive = true) { IfcRelDefinesByProperties rel = caseSensitive ? elem.IsDefinedByProperties.Where(r => r.RelatingPropertyDefinition.Name == pSetName && r.RelatingPropertyDefinition is IfcElementQuantity).FirstOrDefault() : elem.IsDefinedByProperties.Where(r => r.RelatingPropertyDefinition.Name.ToString().ToLower() == pSetName.ToLower() && r.RelatingPropertyDefinition is IfcElementQuantity).FirstOrDefault(); if (rel != null) { return(rel.RelatingPropertyDefinition as IfcElementQuantity); } else { return(null); } }
/// <summary> /// Returns the first quantity that matches the quantity name /// </summary> /// <typeparam name="QType"></typeparam> /// <param name="elem"></param> /// <param name="qName"></param> /// <returns></returns> public static QType GetQuantity <QType>(this IfcObject elem, string qName) where QType : IfcPhysicalQuantity { IfcRelDefinesByProperties rel = elem.IsDefinedByProperties.Where(r => r.RelatingPropertyDefinition is IfcElementQuantity).FirstOrDefault(); if (rel != null) { IfcElementQuantity eQ = rel.RelatingPropertyDefinition as IfcElementQuantity; if (eQ != null) { QType result = eQ.Quantities.Where <QType>(q => q.Name == qName).FirstOrDefault(); return(result); } } return(default(QType)); }
protected BbPropertySet(string name) { IfcPropertySet = new IfcPropertySet { Name = name, GlobalId = IfcGloballyUniqueId.NewGuid(), OwnerHistory = BbHeaderSetting.Setting3D.IfcOwnerHistory, HasProperties = new List<IfcProperty>(), }; IfcRelDefinesByProperties = new IfcRelDefinesByProperties { GlobalId = IfcGloballyUniqueId.NewGuid(), OwnerHistory = BbHeaderSetting.Setting3D.IfcOwnerHistory, RelatedObjects = new List<IfcObject>(), RelatingPropertyDefinition = IfcPropertySet, }; }
protected BbPropertySet(string name) { IfcPropertySet = new IfcPropertySet { Name = name, GlobalId = IfcGloballyUniqueId.NewGuid(), OwnerHistory = BbHeaderSetting.Setting3D.IfcOwnerHistory, HasProperties = new List <IfcProperty>(), }; IfcRelDefinesByProperties = new IfcRelDefinesByProperties { GlobalId = IfcGloballyUniqueId.NewGuid(), OwnerHistory = BbHeaderSetting.Setting3D.IfcOwnerHistory, RelatedObjects = new List <IfcObject>(), RelatingPropertyDefinition = IfcPropertySet, }; }
/// <summary> /// Adds a new IfcPhysicalQuantity to the IfcElementQuantity called propertySetName /// </summary> /// <param name="elem"></param> /// <param name="propertySetName">Name of the IfcElementQuantity property set</param> /// <param name="quantity">quantity to be added</param> /// <param name="methodOfMeasurement">Sets the method of measurement, if not null overrides previous value</param> public static IfcElementQuantity AddQuantity(this IfcObject elem, string propertySetName, IfcPhysicalQuantity quantity, string methodOfMeasurement) { IfcElementQuantity pset = elem.GetElementQuantity(propertySetName); if (pset == null) { IModel model = elem.ModelOf; pset = model.Instances.New <IfcElementQuantity>(); pset.Name = propertySetName; IfcRelDefinesByProperties relDef = model.Instances.New <IfcRelDefinesByProperties>(); relDef.RelatingPropertyDefinition = pset; relDef.RelatedObjects.Add(elem); } pset.Quantities.Add(quantity); if (!string.IsNullOrEmpty(methodOfMeasurement)) { pset.MethodOfMeasurement = methodOfMeasurement; } return(pset); }
BbQuantityRequired() { IfcQuantityCount = new IfcQuantityCount { Name = "Quantity", CountValue = 0, }; IfcElementQuantity = new IfcElementQuantity { GlobalId = IfcGloballyUniqueId.NewGuid(), OwnerHistory = BbHeaderSetting.Setting3D.IfcOwnerHistory, Quantities = new List<IfcPhysicalQuantity>{IfcQuantityCount}, }; IfcRelDefinesByProperties = new IfcRelDefinesByProperties { GlobalId = IfcGloballyUniqueId.NewGuid(), OwnerHistory = BbHeaderSetting.Setting3D.IfcOwnerHistory, RelatedObjects = new List<IfcObject>(), RelatingPropertyDefinition = IfcElementQuantity, }; }
private static IEnumerable <IfcPropertySetDefinition> GetDefinitions(IfcRelDefinesByProperties r) { if (r.RelatingPropertyDefinition == null) { return(null); } var defSelect = r.RelatingPropertyDefinition; var def = defSelect as IfcPropertySetDefinition; if (def != null) { return new[] { def } } ; if (defSelect is IfcPropertySetDefinitionSet) { return (((IfcPropertySetDefinitionSet)defSelect).Value as IEnumerable <IfcPropertySetDefinition>); } return(null); } }
BbQuantityRequired() { IfcQuantityCount = new IfcQuantityCount { Name = "Quantity", CountValue = 0, }; IfcElementQuantity = new IfcElementQuantity { GlobalId = IfcGloballyUniqueId.NewGuid(), OwnerHistory = BbHeaderSetting.Setting3D.IfcOwnerHistory, Quantities = new List <IfcPhysicalQuantity> { IfcQuantityCount }, }; IfcRelDefinesByProperties = new IfcRelDefinesByProperties { GlobalId = IfcGloballyUniqueId.NewGuid(), OwnerHistory = BbHeaderSetting.Setting3D.IfcOwnerHistory, RelatedObjects = new List <IfcObject>(), RelatingPropertyDefinition = IfcElementQuantity, }; }
/// <summary> /// Fill sheet rows for System sheet /// </summary> /// <returns>COBieSheet</returns> public COBieSheet<COBieSystemRow> Fill(Dictionary<string, HashSet<string>> compIndices) { ProgressIndicator.ReportMessage("Starting Systems..."); //Create new sheet COBieSheet<COBieSystemRow> systems = new COBieSheet<COBieSystemRow>(Constants.WORKSHEET_SYSTEM); // get all IfcSystem, IfcGroup and IfcElectricalCircuit objects from IFC file IEnumerable<IfcGroup> ifcGroups = Model.FederatedInstances.OfType<IfcGroup>().Where(ifcg => ifcg is IfcSystem); //get anything that is IfcSystem or derived from it eg IfcElectricalCircuit //IEnumerable<IfcSystem> ifcSystems = Model.FederatedInstances.OfType<IfcSystem>(); //IEnumerable<IfcElectricalCircuit> ifcElectricalCircuits = Model.FederatedInstances.OfType<IfcElectricalCircuit>(); //ifcGroups = ifcGroups.Union(ifcSystems); //ifcGroups = ifcGroups.Union(ifcElectricalCircuits); //Alternative method of extraction List<string> PropertyNames = new List<string> { "Circuit Number", "System Name" }; IEnumerable<IfcPropertySet> ifcPropertySets = from ps in Model.FederatedInstances.OfType<IfcPropertySet>() from psv in ps.HasProperties.OfType<IfcPropertySingleValue>() where PropertyNames.Contains(psv.Name) select ps; ProgressIndicator.Initialise("Creating Systems", ifcGroups.Count() + ifcPropertySets.Count()); foreach (IfcGroup ifcGroup in ifcGroups) { ProgressIndicator.IncrementAndUpdate(); IEnumerable<IfcProduct> ifcProducts = (ifcGroup.IsGroupedBy == null) ? Enumerable.Empty<IfcProduct>() : ifcGroup.IsGroupedBy.RelatedObjects.OfType<IfcProduct>(); foreach (IfcProduct product in ifcProducts) { COBieSystemRow sys = new COBieSystemRow(systems); sys.Name = ifcGroup.Name; sys.CreatedBy = GetTelecomEmailAddress(ifcGroup.OwnerHistory); sys.CreatedOn = GetCreatedOnDateAsFmtString(ifcGroup.OwnerHistory); sys.Category = GetCategory(ifcGroup); string name = product.Name; if (string.IsNullOrEmpty(product.Name) || (product.Name == Constants.DEFAULT_STRING)) { name = product.GetType().Name + " Name Unknown " + UnknownCount.ToString(); UnknownCount++; } else { if (compIndices.Count > 0) //check we have values { //check for name in components , if missing exclude from system, unknown names are listed see above if (!compIndices["Name"].Contains(name, StringComparer.OrdinalIgnoreCase)) continue; } } sys.ComponentNames = product.Name; sys.ExtSystem = GetExternalSystem(ifcGroup); sys.ExtObject = ifcGroup.GetType().Name; //need to create product if filtered out in the components sheet if (!string.IsNullOrEmpty(ifcGroup.GlobalId)) { sys.ExtIdentifier = ifcGroup.GlobalId;//need to create product if filtered out in the components sheet } sys.Description = GetSystemDescription(ifcGroup); systems.AddRow(sys); } //check if no products then add group only, new line for each, or should we do as assembly? conCant with : if (!ifcProducts.Any()) { COBieSystemRow sys = new COBieSystemRow(systems); sys.Name = ifcGroup.Name; sys.CreatedBy = GetTelecomEmailAddress(ifcGroup.OwnerHistory); sys.CreatedOn = GetCreatedOnDateAsFmtString(ifcGroup.OwnerHistory); sys.Category = GetCategory(ifcGroup); sys.ComponentNames = DEFAULT_STRING; sys.ExtSystem = GetExternalSystem(ifcGroup); sys.ExtObject = ifcGroup.GetType().Name; if (!string.IsNullOrEmpty(ifcGroup.GlobalId)) { sys.ExtIdentifier = ifcGroup.GlobalId; } sys.Description = GetSystemDescription(ifcGroup); systems.AddRow(sys); } } foreach (IfcPropertySet ifcPropertySet in ifcPropertySets) { ProgressIndicator.IncrementAndUpdate(); string name = ""; IfcRelDefinesByProperties ifcRelDefinesByProperties = ifcPropertySet.PropertyDefinitionOf.FirstOrDefault(); //one or zero IfcPropertySingleValue ifcPropertySingleValue = ifcPropertySet.HasProperties.OfType<IfcPropertySingleValue>().Where(psv => PropertyNames.Contains(psv.Name)).FirstOrDefault(); if ((ifcPropertySingleValue != null) && (ifcPropertySingleValue.NominalValue != null) && (!string.IsNullOrEmpty(ifcPropertySingleValue.NominalValue.ToString()))) name = ifcPropertySingleValue.NominalValue.ToString(); else //try for "System Classification" Not in matrix but looks a good candidate { IfcPropertySingleValue ifcPropertySVClassification = ifcPropertySet.HasProperties.OfType<IfcPropertySingleValue>().Where(psv => psv.Name == "System Classification").FirstOrDefault(); if ((ifcPropertySVClassification != null) && (ifcPropertySVClassification.NominalValue != null) && (!string.IsNullOrEmpty(ifcPropertySVClassification.NominalValue.ToString()))) name = ifcPropertySVClassification.NominalValue.ToString(); } foreach (IfcObject ifcObject in ifcRelDefinesByProperties.RelatedObjects) { if (ifcObject != null) { COBieSystemRow sys = new COBieSystemRow(systems); //OK if we have no name lets just guess at the first value as we need a value if (string.IsNullOrEmpty(name)) { //get first text value held in NominalValue var names = ifcPropertySet.HasProperties.OfType<IfcPropertySingleValue>().Where(psv => (psv.NominalValue != null) && (!string.IsNullOrEmpty(psv.NominalValue.ToString()))).Select(psv => psv.NominalValue).FirstOrDefault(); if (names != null) { name = names.ToString(); } else { //OK last chance, lets take the property name that is not in the filter list of strings, ie. != "Circuit Number", "System Name" or "System Classification" from above IfcPropertySingleValue propname = ifcPropertySet.HasProperties.OfType<IfcPropertySingleValue>().Where(psv => !PropertyNames.Contains(psv.Name)).FirstOrDefault(); if (propname != null) name = propname.Name.ToString(); } } sys.Name = string.IsNullOrEmpty(name) ? DEFAULT_STRING : name; sys.CreatedBy = GetTelecomEmailAddress(ifcObject.OwnerHistory); sys.CreatedOn = GetCreatedOnDateAsFmtString(ifcObject.OwnerHistory); sys.Category = (ifcPropertySingleValue.Name == "Circuit Number") ? "circuit" : GetCategory(ifcObject); //per matrix v9 //check that the element is in the component list if (compIndices.Count > 0) //check we have values { //check for name in components , if missing exclude from system, unknown names are listed see above if (!compIndices["Name"].Contains(ifcObject.Name.ToString(), StringComparer.OrdinalIgnoreCase)) continue; } sys.ComponentNames = ifcObject.Name; sys.ExtSystem = GetExternalSystem(ifcPropertySet); sys.ExtObject = ifcPropertySingleValue.GetType().Name; sys.Description = string.IsNullOrEmpty(name) ? DEFAULT_STRING : name; ; systems.AddRow(sys); } } } systems.OrderBy(s => s.Name); ProgressIndicator.Finalise(); return systems; }
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; }); }
private static void CreateElementQuantity(XbimModel model, IfcWallStandardCase wall, IfcOwnerHistory ifcOwnerHistory) { //Create a IfcElementQuantity //first we need a IfcPhysicalSimpleQuantity,first will use IfcQuantityArea IfcQuantityArea ifcQuantityArea = model.Instances.New <IfcQuantityArea>(qa => { qa.Name = "IfcQuantityArea:Area"; qa.Description = ""; qa.Unit = model.Instances.New <IfcSIUnit>(siu => { siu.UnitType = IfcUnitEnum.AREAUNIT; siu.Prefix = IfcSIPrefix.MILLI; siu.Name = IfcSIUnitName.SQUARE_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; }); }); qa.AreaValue = 100.0; }); //next quantity IfcQuantityCount using IfcContextDependentUnit IfcContextDependentUnit ifcContextDependentUnit = model.Instances.New <IfcContextDependentUnit>(cd => { cd.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; }); cd.UnitType = IfcUnitEnum.LENGTHUNIT; cd.Name = "Elephants"; }); IfcQuantityCount ifcQuantityCount = model.Instances.New <IfcQuantityCount>(qc => { qc.Name = "IfcQuantityCount:Elephant"; qc.CountValue = 12; qc.Unit = ifcContextDependentUnit; }); //next quantity IfcQuantityLength using IfcConversionBasedUnit IfcConversionBasedUnit ifcConversionBasedUnit = model.Instances.New <IfcConversionBasedUnit>(cbu => { cbu.ConversionFactor = model.Instances.New <IfcMeasureWithUnit>(mu => { mu.ValueComponent = new IfcRatioMeasure(25.4); mu.UnitComponent = model.Instances.New <IfcSIUnit>(siu => { siu.UnitType = IfcUnitEnum.LENGTHUNIT; siu.Prefix = IfcSIPrefix.MILLI; siu.Name = IfcSIUnitName.METRE; }); }); cbu.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; }); cbu.UnitType = IfcUnitEnum.LENGTHUNIT; cbu.Name = "Inch"; }); IfcQuantityLength ifcQuantityLength = model.Instances.New <IfcQuantityLength>(qa => { qa.Name = "IfcQuantityLength:Length"; qa.Description = ""; qa.Unit = ifcConversionBasedUnit; qa.LengthValue = 24.0; }); //lets create the IfcElementQuantity IfcElementQuantity ifcElementQuantity = model.Instances.New <IfcElementQuantity>(eq => { eq.OwnerHistory = ifcOwnerHistory; eq.Name = "Test:IfcElementQuantity"; eq.Description = "Measurement quantity"; eq.Quantities.Add(ifcQuantityArea); eq.Quantities.Add(ifcQuantityCount); eq.Quantities.Add(ifcQuantityLength); }); //need to create the relationship IfcRelDefinesByProperties ifcRelDefinesByProperties = model.Instances.New <IfcRelDefinesByProperties>(rdbp => { rdbp.OwnerHistory = ifcOwnerHistory; rdbp.Name = "Area Association"; rdbp.Description = "IfcElementQuantity associated to wall"; rdbp.RelatedObjects.Add(wall); rdbp.RelatingPropertyDefinition = ifcElementQuantity; }); }