public static IfcNamedUnit GetVolumeUnit(this IfcUnitAssignment ua) { IfcNamedUnit nu = ua.Units.OfType <IfcSIUnit>().FirstOrDefault(u => u.UnitType == IfcUnitEnum.VOLUMEUNIT); if (nu == null) { nu = ua.Units.OfType <IfcConversionBasedUnit>().FirstOrDefault(u => u.UnitType == IfcUnitEnum.VOLUMEUNIT); } return(nu); }
public static IfcNamedUnit GetUnitFor(this IfcUnitAssignment ua, IfcPhysicalSimpleQuantity Quantity) { if (Quantity.Unit != null) { return(Quantity.Unit); } IfcUnitEnum?requiredUnit = null; // list of possible types taken from: // http://www.buildingsmart-tech.org/ifc/IFC2x3/TC1/html/ifcquantityresource/lexical/ifcphysicalsimplequantity.htm // if (Quantity is IfcQuantityLength) { requiredUnit = IfcUnitEnum.LENGTHUNIT; } else if (Quantity is IfcQuantityArea) { requiredUnit = IfcUnitEnum.AREAUNIT; } else if (Quantity is IfcQuantityVolume) { requiredUnit = IfcUnitEnum.VOLUMEUNIT; } else if (Quantity is IfcQuantityCount) // really not sure what to do here. { return(null); } else if (Quantity is IfcQuantityWeight) { requiredUnit = IfcUnitEnum.MASSUNIT; } else if (Quantity is IfcQuantityTime) { requiredUnit = IfcUnitEnum.TIMEUNIT; } if (requiredUnit == null) { return(null); } IfcNamedUnit nu = ua.Units.OfType <IfcSIUnit>().FirstOrDefault(u => u.UnitType == (IfcUnitEnum)requiredUnit); if (nu == null) { nu = ua.Units.OfType <IfcConversionBasedUnit>().FirstOrDefault(u => u.UnitType == (IfcUnitEnum)requiredUnit); } return(nu); }
public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex) { switch (propIndex) { case 0: case 1: base.Parse(propIndex, value, nestedIndex); return; case 2: _unit = (IfcNamedUnit)(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: base.IfcParse(propIndex, value); break; case 2: _unit = (IfcNamedUnit)value.EntityVal; break; default: this.HandleUnexpectedAttribute(propIndex, value); break; } }
/// <summary> /// Get the symbol of the IfcNamedUnit /// </summary> /// <returns>string holding symbol</returns> public static string GetSymbol(this IfcNamedUnit namedUnit) { if (namedUnit is IfcSIUnit) { return(((IfcSIUnit)namedUnit).GetSymbol()); } else if (namedUnit is IfcConversionBasedUnit) { return(((IfcConversionBasedUnit)namedUnit).Name); //elected not to get symbol as a small potential for a infinite loop is same object references itself } else if (namedUnit is IfcContextDependentUnit) { return(((IfcContextDependentUnit)namedUnit).Name); //no symbol calc here } else { return(string.Empty); } }
/// <summary> /// Get the full name of the IfcNamedUnit /// </summary> /// <returns>string holding full name</returns> public static string GetName(this IfcNamedUnit namedUnit) { if (namedUnit is IfcSIUnit) { return(((IfcSIUnit)namedUnit).GetName()); } else if (namedUnit is IfcConversionBasedUnit) { return(((IfcConversionBasedUnit)namedUnit).Name); } else if (namedUnit is IfcContextDependentUnit) { return(((IfcContextDependentUnit)namedUnit).Name); } else { return(string.Empty); } }
public IfcPhysicalSimpleQuantity(IfcLabel __Name, IfcText?__Description, IfcNamedUnit __Unit) : base(__Name, __Description) { this._Unit = __Unit; }
public IfcQuantityWeight(IfcLabel __Name, IfcText?__Description, IfcNamedUnit __Unit, IfcMassMeasure __WeightValue, IfcLabel?__Formula) : base(__Name, __Description, __Unit) { this._WeightValue = __WeightValue; this._Formula = __Formula; }
public IfcQuantityArea(IfcLabel __Name, IfcText?__Description, IfcNamedUnit __Unit, IfcAreaMeasure __AreaValue, IfcLabel?__Formula) : base(__Name, __Description, __Unit) { this._AreaValue = __AreaValue; this._Formula = __Formula; }
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); }
public IfcQuantityCount(IfcLabel __Name, IfcText?__Description, IfcNamedUnit __Unit, IfcCountMeasure __CountValue) : base(__Name, __Description, __Unit) { this._CountValue = __CountValue; }
/// <summary> /// Get the global units used for this building /// </summary> /// <param name="model">model object</param> /// <param name="wBookUnits">GlobalUnits to place units into</param> /// <returns>return passed wBookUnits(GlobalUnits) with units added</returns> public static GlobalUnits GetGlobalUnits(IModel model, GlobalUnits wBookUnits) { string linearUnit = ""; string areaUnit = ""; string volumeUnit = ""; string moneyUnit = ""; foreach (IfcUnitAssignment ifcUnitAssignment in model.Instances.OfType <IfcUnitAssignment>()) //loop all IfcUnitAssignment { foreach (IfcUnit ifcUnit in ifcUnitAssignment.Units) //loop the UnitSet { IfcNamedUnit ifcNamedUnit = ifcUnit as IfcNamedUnit; if (ifcNamedUnit != null) { if ((ifcNamedUnit.UnitType == IfcUnitEnum.LENGTHUNIT) && string.IsNullOrEmpty(linearUnit)) //we want length units until we have value { linearUnit = GetUnitName(ifcUnit); if ((!((linearUnit.Contains("feet")) || (linearUnit.Contains("foot")))) && (linearUnit.Last() != 's') ) { linearUnit = linearUnit + "s"; } } if ((ifcNamedUnit.UnitType == IfcUnitEnum.AREAUNIT) && string.IsNullOrEmpty(areaUnit)) //we want area units until we have value { areaUnit = GetUnitName(ifcUnit); if ((!((areaUnit.Contains("feet")) || (areaUnit.Contains("foot")))) && (areaUnit.Last() != 's') ) { areaUnit = areaUnit + "s"; } } if ((ifcNamedUnit.UnitType == IfcUnitEnum.VOLUMEUNIT) && string.IsNullOrEmpty(volumeUnit)) //we want volume units until we have value { volumeUnit = GetUnitName(ifcUnit); if ((!((volumeUnit.Contains("feet")) || (volumeUnit.Contains("foot")))) && (volumeUnit.Last() != 's') ) { volumeUnit = volumeUnit + "s"; } } } //get the money unit if ((ifcUnit is IfcMonetaryUnit) && string.IsNullOrEmpty(moneyUnit)) { moneyUnit = GetUnitName(ifcUnit); if (moneyUnit.Last() != 's') { moneyUnit = moneyUnit + "s"; } } } } //ensure we have a value on each unit type, if not then default linearUnit = string.IsNullOrEmpty(linearUnit) ? DEFAULT_STRING : linearUnit; areaUnit = string.IsNullOrEmpty(areaUnit) ? DEFAULT_STRING : areaUnit; volumeUnit = string.IsNullOrEmpty(volumeUnit) ? DEFAULT_STRING : volumeUnit; moneyUnit = string.IsNullOrEmpty(moneyUnit) ? DEFAULT_STRING : moneyUnit; //save values for retrieval by other sheets wBookUnits.LengthUnit = linearUnit; wBookUnits.AreaUnit = areaUnit; wBookUnits.VolumeUnit = volumeUnit; wBookUnits.MoneyUnit = moneyUnit; return(wBookUnits); }
public IfcQuantityLength(IfcLabel __Name, IfcText?__Description, IfcNamedUnit __Unit, IfcLengthMeasure __LengthValue) : base(__Name, __Description, __Unit) { this._LengthValue = __LengthValue; }
public IfcProjectedCRS(IfcLabel __Name, IfcText?__Description, IfcIdentifier?__GeodeticDatum, IfcIdentifier?__VerticalDatum, IfcIdentifier?__MapProjection, IfcIdentifier?__MapZone, IfcNamedUnit __MapUnit) : base(__Name, __Description, __GeodeticDatum, __VerticalDatum) { this.MapProjection = __MapProjection; this.MapZone = __MapZone; this.MapUnit = __MapUnit; }
public IfcQuantityTime(IfcLabel __Name, IfcText?__Description, IfcNamedUnit __Unit, IfcTimeMeasure __TimeValue) : base(__Name, __Description, __Unit) { this._TimeValue = __TimeValue; }
public static IfcNamedUnit GetUnitFor(this IfcUnitAssignment ua, IfcPropertySingleValue Property) { if (Property.Unit != null) { return((IfcNamedUnit)Property.Unit); } // nominal value can be of types with subtypes: // IfcMeasureValue, IfcSimpleValue, IfcDerivedMeasureValue IfcUnitEnum?requiredUnit = null; // types from http://www.buildingsmart-tech.org/ifc/IFC2x3/TC1/html/ifcmeasureresource/lexical/ifcmeasurevalue.htm if (Property.NominalValue is IfcVolumeMeasure) { requiredUnit = IfcUnitEnum.VOLUMEUNIT; } else if (Property.NominalValue is IfcAreaMeasure) { requiredUnit = IfcUnitEnum.AREAUNIT; } else if (Property.NominalValue is IfcLengthMeasure) { requiredUnit = IfcUnitEnum.LENGTHUNIT; } else if (Property.NominalValue is IfcPositiveLengthMeasure) { requiredUnit = IfcUnitEnum.LENGTHUNIT; } else if (Property.NominalValue is IfcAmountOfSubstanceMeasure) { requiredUnit = IfcUnitEnum.AMOUNTOFSUBSTANCEUNIT; } else if (Property.NominalValue is IfcContextDependentMeasure) { requiredUnit = null; // todo: not sure what to do here } else if (Property.NominalValue is IfcCountMeasure) { requiredUnit = null; // todo: not sure what to do here } else if (Property.NominalValue is IfcDescriptiveMeasure) { requiredUnit = null; // todo: not sure what to do here } else if (Property.NominalValue is IfcElectricCurrentMeasure) { requiredUnit = IfcUnitEnum.ELECTRICCURRENTUNIT; } else if (Property.NominalValue is IfcLuminousIntensityMeasure) { requiredUnit = IfcUnitEnum.LUMINOUSINTENSITYUNIT; } else if (Property.NominalValue is IfcMassMeasure) { requiredUnit = IfcUnitEnum.MASSUNIT; } else if (Property.NominalValue is IfcNormalisedRatioMeasure) { requiredUnit = null; // todo: not sure what to do here } else if (Property.NominalValue is IfcNumericMeasure) { requiredUnit = null; // todo: not sure what to do here. } else if (Property.NominalValue is IfcParameterValue) { requiredUnit = null; // todo: not sure what to do here. } else if (Property.NominalValue is IfcPlaneAngleMeasure) { requiredUnit = IfcUnitEnum.PLANEANGLEUNIT; } else if (Property.NominalValue is IfcPositiveRatioMeasure) { requiredUnit = null; // todo: not sure what to do here. } else if (Property.NominalValue is IfcPositivePlaneAngleMeasure) { requiredUnit = IfcUnitEnum.PLANEANGLEUNIT; } else if (Property.NominalValue is IfcRatioMeasure) { requiredUnit = null; // todo: not sure what to do here. } else if (Property.NominalValue is IfcSolidAngleMeasure) { requiredUnit = IfcUnitEnum.SOLIDANGLEUNIT; } else if (Property.NominalValue is IfcThermodynamicTemperatureMeasure) { requiredUnit = IfcUnitEnum.THERMODYNAMICTEMPERATUREUNIT; } else if (Property.NominalValue is IfcTimeMeasure) { requiredUnit = IfcUnitEnum.TIMEUNIT; } else if (Property.NominalValue is IfcComplexNumber) { requiredUnit = null; // todo: not sure what to do here. } // types from IfcSimpleValue else if (Property.NominalValue is IfcSimpleValue) { requiredUnit = null; } // more measures types to be taken from http://www.buildingsmart-tech.org/ifc/IFC2x3/TC1/html/ifcmeasureresource/lexical/ifcderivedmeasurevalue.htm if (requiredUnit == null) { return(null); } IfcNamedUnit nu = ua.Units.OfType <IfcSIUnit>().FirstOrDefault(u => u.UnitType == (IfcUnitEnum)requiredUnit); if (nu == null) { nu = ua.Units.OfType <IfcConversionBasedUnit>().FirstOrDefault(u => u.UnitType == (IfcUnitEnum)requiredUnit); } return(nu); }
public IfcQuantityVolume(IfcLabel __Name, IfcText?__Description, IfcNamedUnit __Unit, IfcVolumeMeasure __VolumeValue, IfcLabel?__Formula) : base(__Name, __Description, __Unit) { this._VolumeValue = __VolumeValue; this._Formula = __Formula; }
public void SetElementPhysicalSimpleQuantity(string qSetName, string qualityName, double value, XbimQuantityTypeEnum quantityType, IfcNamedUnit unit) { var qset = GetElementQuantity(qSetName) as IfcElementQuantity; if (qset == null) { qset = Model.Instances.New <IfcElementQuantity>(); qset.Name = qSetName; var relDef = Model.Instances.New <IfcRelDefinesByProperties>(); relDef.RelatingPropertyDefinition = qset; relDef.RelatedObjects.Add(this); } //remove existing simple quality var simpleQuantity = GetElementPhysicalSimpleQuantity(qSetName, qualityName) as IfcPhysicalSimpleQuantity; if (simpleQuantity == null) { switch (quantityType) { case XbimQuantityTypeEnum.Area: simpleQuantity = Model.Instances.New <IfcQuantityArea>(sq => sq.AreaValue = (IfcAreaMeasure)value); break; case XbimQuantityTypeEnum.Count: simpleQuantity = Model.Instances.New <IfcQuantityCount>(sq => sq.CountValue = (IfcCountMeasure)value); break; case XbimQuantityTypeEnum.Length: simpleQuantity = Model.Instances.New <IfcQuantityLength>(sq => sq.LengthValue = (IfcLengthMeasure)value); break; case XbimQuantityTypeEnum.Time: simpleQuantity = Model.Instances.New <IfcQuantityTime>(sq => sq.TimeValue = (IfcTimeMeasure)value); break; case XbimQuantityTypeEnum.Volume: simpleQuantity = Model.Instances.New <IfcQuantityVolume>(sq => sq.VolumeValue = (IfcVolumeMeasure)value); break; case XbimQuantityTypeEnum.Weight: simpleQuantity = Model.Instances.New <IfcQuantityWeight>(sq => sq.WeightValue = (IfcMassMeasure)value); break; default: return; } } else { switch (quantityType) { case XbimQuantityTypeEnum.Area: ((IfcQuantityArea)simpleQuantity).AreaValue = new IfcAreaMeasure(value); break; case XbimQuantityTypeEnum.Count: ((IfcQuantityCount)simpleQuantity).CountValue = new IfcCountMeasure(value); break; case XbimQuantityTypeEnum.Length: ((IfcQuantityLength)simpleQuantity).LengthValue = new IfcLengthMeasure(value); break; case XbimQuantityTypeEnum.Time: ((IfcQuantityTime)simpleQuantity).TimeValue = new IfcTimeMeasure(value); break; case XbimQuantityTypeEnum.Volume: ((IfcQuantityVolume)simpleQuantity).VolumeValue = new IfcVolumeMeasure(value); break; case XbimQuantityTypeEnum.Weight: ((IfcQuantityWeight)simpleQuantity).WeightValue = new IfcMassMeasure(value); break; default: return; } } simpleQuantity.Unit = unit; simpleQuantity.Name = qualityName; qset.Quantities.Add(simpleQuantity); }
public static void SetElementPhysicalSimpleQuantity(this IfcTypeObject elem, string qSetName, string qualityName, double value, XbimQuantityTypeEnum quantityType, IfcNamedUnit unit) { IModel model = null; if (elem is IPersistIfcEntity) { model = (elem as IPersistIfcEntity).ModelOf; } else { model = elem.ModelOf; } IfcElementQuantity qset = GetElementQuantity(elem, qSetName); if (qset == null) { qset = model.Instances.New <IfcElementQuantity>(); qset.Name = qSetName; if (elem.HasPropertySets == null) { elem.CreateHasPropertySets(); } elem.HasPropertySets.Add(qset); } //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 = value); break; case XbimQuantityTypeEnum.COUNT: simpleQuality = model.Instances.New <IfcQuantityCount>(sq => sq.CountValue = value); break; case XbimQuantityTypeEnum.LENGTH: simpleQuality = model.Instances.New <IfcQuantityLength>(sq => sq.LengthValue = value); break; case XbimQuantityTypeEnum.TIME: simpleQuality = model.Instances.New <IfcQuantityTime>(sq => sq.TimeValue = value); break; case XbimQuantityTypeEnum.VOLUME: simpleQuality = model.Instances.New <IfcQuantityVolume>(sq => sq.VolumeValue = value); break; case XbimQuantityTypeEnum.WEIGHT: simpleQuality = model.Instances.New <IfcQuantityWeight>(sq => sq.WeightValue = value); break; default: return; } simpleQuality.Unit = unit; simpleQuality.Name = qualityName; qset.Quantities.Add(simpleQuality); }