private static CcManufacturerProductDetail GetDetailsFromProperty(IfcProperty prop) { CcManufacturerProductDetail result = null; if (prop is IfcPropertySingleValue) { IfcPropertySingleValue single = prop as IfcPropertySingleValue; result = new CcManufacturerProductDetail() { AttributeName = single.Name }; result.AttributeValue = GetNominalValue(single.NominalValue); } else if (prop is IfcPropertyEnumeratedValue) { IfcPropertyEnumeratedValue enumval = prop as IfcPropertyEnumeratedValue; result = new CcManufacturerProductDetail() { AttributeName = enumval.Name, AttributeDescription = enumval.Description }; result.AttributeValue = GetEnumeratedValue(enumval.EnumerationValues); } else { throw new NotImplementedException(); } return(result); }
//Demonstration of approach to filter out fire rated walls into seperate IFC file static void Main(string[] args) { DatabaseIfc db = new DatabaseIfc(args[0]); DuplicateOptions duplicateOptions = new DuplicateOptions(db.Tolerance); duplicateOptions.DuplicateDownstream = false; DatabaseIfc filteredDb = new DatabaseIfc(db); IfcProject project = filteredDb.Factory.Duplicate(db.Project, duplicateOptions) as IfcProject; duplicateOptions.DuplicateDownstream = true; List <IfcWall> walls = db.Project.Extract <IfcWall>(); foreach (IfcWall wall in walls) { IfcPropertySingleValue property = wall.FindProperty("FireRating", true) as IfcPropertySingleValue; if (property != null && property.NominalValue != null) { string value = property.NominalValue.ValueString.Trim(); if (value != "0") { filteredDb.Factory.Duplicate(wall, duplicateOptions); } } } filteredDb.WriteFile(args[1]); }
public static Dictionary <IfcLabel, Dictionary <IfcIdentifier, IfcValue> > GetAllPropertySingleValues( this IfcMaterial material, IModel model) { IEnumerable <IfcExtendedMaterialProperties> pSets = model.Instances.Where <IfcExtendedMaterialProperties>(pset => pset.Material == material); Dictionary <IfcLabel, Dictionary <IfcIdentifier, IfcValue> > result = new Dictionary <IfcLabel, Dictionary <IfcIdentifier, IfcValue> >(); foreach (IfcExtendedMaterialProperties pSet in pSets) { Dictionary <IfcIdentifier, IfcValue> value = new Dictionary <IfcIdentifier, IfcValue>(); IfcLabel psetName = pSet.Name; foreach (IfcProperty prop in pSet.ExtendedProperties) { IfcPropertySingleValue singleVal = prop as IfcPropertySingleValue; if (singleVal == null) { continue; } value.Add(prop.Name, singleVal.NominalValue); } result.Add(psetName, value); } return(result); }
public static Dictionary <IfcLabel, Dictionary <IfcIdentifier, IfcValue> > GetAllPropertySingleValues(this Xbim.Ifc2x3.Kernel.IfcObject obj) { Dictionary <IfcLabel, Dictionary <IfcIdentifier, IfcValue> > result = new Dictionary <IfcLabel, Dictionary <IfcIdentifier, IfcValue> >(); IEnumerable <IfcRelDefinesByProperties> relations = obj.IsDefinedByProperties.OfType <IfcRelDefinesByProperties>(); foreach (IfcRelDefinesByProperties rel in relations) { Dictionary <IfcIdentifier, IfcValue> value = new Dictionary <IfcIdentifier, IfcValue>(); IfcLabel psetName = rel.RelatingPropertyDefinition.Name ?? null; IfcPropertySet pSet = rel.RelatingPropertyDefinition as IfcPropertySet; if (pSet == null) { continue; } foreach (IfcProperty prop in pSet.HasProperties) { IfcPropertySingleValue singleVal = prop as IfcPropertySingleValue; if (singleVal == null) { continue; } value.Add(prop.Name, singleVal.NominalValue); } if (!result.ContainsKey(psetName)) { result.Add(psetName, value); } } return(result); }
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); }
public static Dictionary <IfcLabel, Dictionary <IfcIdentifier, IfcValue> > GetAllPropertySingleValues(this Xbim.Ifc2x3.Kernel.IfcTypeObject obj) { Dictionary <IfcLabel, Dictionary <IfcIdentifier, IfcValue> > result = new Dictionary <IfcLabel, Dictionary <IfcIdentifier, IfcValue> >(); PropertySetDefinitionSet pSets = obj.HasPropertySets; if (pSets == null) { return(result); } IEnumerable <IfcPropertySet> pSetsPure = pSets.OfType <IfcPropertySet>(); foreach (IfcPropertySet pSet in pSetsPure) { Dictionary <IfcIdentifier, IfcValue> value = new Dictionary <IfcIdentifier, IfcValue>(); IfcLabel psetName = pSet.Name ?? null; foreach (IfcProperty prop in pSet.HasProperties) { IfcPropertySingleValue singleVal = prop as IfcPropertySingleValue; if (singleVal == null) { continue; } value.Add(prop.Name, singleVal.NominalValue); } result.Add(psetName, value); } return(result); }
public static IfcPropertySingleValue SetPropertySingleValue(this Xbim.Ifc2x3.Kernel.IfcTypeObject obj, string pSetName, string propertyName, IfcValue value) { IfcPropertySet pset = GetPropertySet(obj, pSetName); IfcPropertySingleValue property = null; IModel model = null; if (pset == null) { //if (value == null) return; IPersistIfcEntity ent = obj as IPersistIfcEntity; model = ent != null? ent.ModelOf : obj.ModelOf; pset = model.Instances.New <IfcPropertySet>(); pset.Name = pSetName; obj.AddPropertySet(pset); } //change existing property of the same name from the property set IfcPropertySingleValue singleVal = GetPropertySingleValue(obj, pSetName, propertyName); if (singleVal != null) { property = singleVal; singleVal.NominalValue = value; } else { //if (value == null) return; IPersistIfcEntity ent = obj as IPersistIfcEntity; model = ent != null ? ent.ModelOf : obj.ModelOf; property = model.Instances.New <IfcPropertySingleValue>(psv => { psv.Name = propertyName; psv.NominalValue = value; }); pset.HasProperties.Add(property); } return(property); }
/// <summary> /// Get Formatted Start Date /// </summary> /// <param name="allPropertyValues"></param> /// <param name="propertyName"></param> /// <returns></returns> private string GetDateFromProperty(COBieDataPropertySetValues allPropertyValues, string propertyName) { string startData = ""; IfcPropertySingleValue ifcPropertySingleValue = allPropertyValues.GetPropertySingleValue(propertyName); if (ifcPropertySingleValue != null) { if (ifcPropertySingleValue.NominalValue != null) { startData = ifcPropertySingleValue.NominalValue.ToString(); } } else { startData = allPropertyValues.GetPropertyValue(propertyName, false); } DateTime frmDate; if (DateTime.TryParse(startData, out frmDate)) { startData = frmDate.ToString(Constants.DATE_FORMAT); } else if (string.IsNullOrEmpty(startData)) { startData = Constants.DEFAULT_STRING;//Context.RunDate; } return(startData); }
/// <summary> /// Get the property value where the property name equals the passed in value. /// Always use SetAllPropertySingleValues before calling this method /// </summary> /// <param name="PropertyValueName">IfcPropertySingleValue name</param> /// <param name="containsString">Do Contains text match on PropertyValueName if true, exact match if false</param> /// <returns></returns> public string GetPropertySingleValueValue(string PropertyValueName, bool containsString) { IfcPropertySingleValue ifcPropertySingleValue = null; if (containsString) { ifcPropertySingleValue = ObjProperties.OfType <IfcPropertySingleValue>().Where(p => p.Name.ToString().Contains(PropertyValueName)).FirstOrDefault(); } else { ifcPropertySingleValue = ObjProperties.OfType <IfcPropertySingleValue>().Where(p => p.Name == PropertyValueName).FirstOrDefault(); } //return a string value if ((ifcPropertySingleValue != null) && (ifcPropertySingleValue.NominalValue != null) && (!string.IsNullOrEmpty(ifcPropertySingleValue.NominalValue.Value.ToString())) && (ifcPropertySingleValue.Name.ToString() != ifcPropertySingleValue.NominalValue.Value.ToString()) //name and value are not the same ) { return(ifcPropertySingleValue.NominalValue.Value.ToString()); } else { return(Constants.DEFAULT_STRING); } }
public static void DeletePropertySingleValueValue(this Xbim.Ifc2x3.Kernel.IfcTypeObject obj, string pSetName, string propertyName) { IfcPropertySingleValue psv = GetPropertySingleValue(obj, pSetName, propertyName); if (psv != null) { psv.NominalValue = null; } }
public bool isApplicable(IfcFlowSegment flowSegment) { // Doubled up Ifc Classification and Uniclass to be confirmed.... IfcPropertySingleValue propertySingleValue = null; IfcSystem system = flowSegment.HasAssignments.OfType <IfcRelAssignsToGroup>().Select(x => x.RelatingGroup).OfType <IfcSystem>().FirstOrDefault(); if (system != null) { propertySingleValue = system.FindProperty("TfNSW_Uniclass_AssetCode") as IfcPropertySingleValue; if (propertySingleValue != null) { if (!propertySingleValue.ValueStringStartsWith("Ss_50_30")) //Drainage collection and distribution systems { return(false); } } IfcDistributionSystem distributionSystem = system as IfcDistributionSystem; if (distributionSystem != null) //IFC4 concept { if (distributionSystem.PredefinedType != IfcDistributionSystemEnum.DRAINAGE) { return(false); } } } propertySingleValue = flowSegment.FindProperty("TfNSW_Uniclass_AssetCode") as IfcPropertySingleValue; if (propertySingleValue != null) { if (propertySingleValue.ValueStringStartsWith("Pr_65_52_63")) // Pipes and fittings { return(true); } } if (flowSegment is IfcDuctSegment) { return(false); } if (flowSegment is IfcCableCarrierSegment) { return(false); } IfcTypeObject typeObject = flowSegment.RelatingType(); if (typeObject is IfcDuctSegmentType) { return(false); } if (typeObject is IfcCableCarrierSegmentType) { return(false); } return(true); }
/// <summary> /// /// </summary> /// <param name="ifcProperty"></param> /// <returns></returns> static public AttributeValue GetAttributeValueType(IfcPropertySingleValue ifcProperty) { var ifcValue = ifcProperty.NominalValue; if (ifcValue == null) { return(null); } if (ifcValue is IfcMonetaryMeasure) { var moneyAttribute = new DecimalAttributeValue { Value = (double)ifcValue.Value }; if (ifcProperty.Unit is IfcMonetaryUnit) { var mu = ifcProperty.Unit as IfcMonetaryUnit; moneyAttribute.Unit = mu.ToString(); } } else if (ifcValue is IfcTimeStamp) { var timeStamp = (IfcTimeStamp)ifcValue; return(new DateTimeAttributeValue { Value = IfcTimeStamp.ToDateTime(timeStamp) }); } else if (ifcValue.UnderlyingSystemType == typeof(int) || ifcValue.UnderlyingSystemType == typeof(long) || ifcValue.UnderlyingSystemType == typeof(short) || ifcValue.UnderlyingSystemType == typeof(byte)) { return(new IntegerAttributeValue { Value = Convert.ToInt32(ifcValue.Value) }); } else if (ifcValue.UnderlyingSystemType == typeof(double) || ifcValue.UnderlyingSystemType == typeof(float)) { return(new DecimalAttributeValue { Value = (double)ifcValue.Value }); } else if (ifcValue.UnderlyingSystemType == typeof(string)) { return(new StringAttributeValue { Value = ifcValue.ToString() }); } else if (ifcValue.UnderlyingSystemType == typeof(bool) || ifcValue.UnderlyingSystemType == typeof(bool?)) { if (ifcValue.Value != null && (bool)ifcValue.Value) { return(new BooleanAttributeValue { Value = (bool)ifcValue.Value }); } return(new BooleanAttributeValue());//return an undefined } return(null); }
protected BbSingleProperty(string name, DateTime value) { Name = name; _ifcValue = new IfcValue(); var iValue = IfcTimeStamp.GetTimeStamp(value); _ifcValue.Value = iValue; _ifcPropertySingleValue = new IfcPropertySingleValue { Name = this.Name, NominalValue = _ifcValue, }; }
//private IfcUnit _ifcUnit; protected BbSingleProperty(string name, string value, Type type) { Name = name; _ifcValue = new IfcValue (); var iValue = Activator.CreateInstance(type) as STRING; iValue.Value = value; _ifcValue.Value = iValue; _ifcPropertySingleValue = new IfcPropertySingleValue{ Name = this.Name, NominalValue = _ifcValue, }; }
//private IfcUnit _ifcUnit; protected BbSingleProperty(string name, string value, Type type) { Name = name; _ifcValue = new IfcValue(); var iValue = Activator.CreateInstance(type) as STRING; iValue.Value = value; _ifcValue.Value = iValue; _ifcPropertySingleValue = new IfcPropertySingleValue { Name = this.Name, NominalValue = _ifcValue, }; }
public static void RemovePropertySingleValue(this Xbim.Ifc2x3.Kernel.IfcObject obj, string pSetName, string propertyName) { IfcPropertySet pset = GetPropertySet(obj, pSetName); if (pset != null) { IfcPropertySingleValue singleValue = pset.HasProperties.Where <IfcPropertySingleValue>(p => p.Name == propertyName).FirstOrDefault(); if (singleValue != null) { pset.HasProperties.Remove(singleValue); } } }
public static VType GetPropertySingleValue <VType>(this Xbim.Ifc2x3.Kernel.IfcObject obj, string pSetName, string propertyName) where VType : IfcValue { IfcPropertySet pset = GetPropertySet(obj, pSetName); if (pset != null) { IfcPropertySingleValue pVal = pset.HasProperties.Where <IfcPropertySingleValue>(p => p.Name == propertyName).FirstOrDefault(); if (pVal != null && typeof(VType).IsAssignableFrom(pVal.NominalValue.GetType())) { return((VType)pVal.NominalValue); } } return(default(VType)); }
protected BbSingleProperty(string name, double value, Type type) { Name = name; _ifcValue = new IfcValue (); var iValue = Activator.CreateInstance(type) as REAL; if (iValue == null) throw new InvalidOperationException(); iValue.Value = value; _ifcValue.Value = iValue; _ifcPropertySingleValue = new IfcPropertySingleValue{ Name = this.Name, NominalValue = _ifcValue, }; }
static void Main(string[] args) { DatabaseIfc db = new DatabaseIfc(ModelView.Ifc4X3NotAssigned); db.Factory.Options.GenerateOwnerHistory = false; IfcProject project = new IfcProject(db, "DemoProject"); IfcProjectLibrary projectLibrary = new IfcProjectLibrary(db, "ClassificationLibrary"); project.AddDeclared(projectLibrary); IfcClassification classification = new IfcClassification(db, "MyClassification"); new IfcRelAssociatesClassification(classification, projectLibrary); IfcClassificationReference buildingElements = new IfcClassificationReference(classification) { Identification = "100", Name = "BuildingElements" }; IfcClassificationReference walls = new IfcClassificationReference(buildingElements) { Identification = "100.100", Name = "Walls" }; IfcClassificationReference partionWalls = new IfcClassificationReference(walls) { Identification = "100.100.002", Name = "PartiionWalls" }; IfcSimplePropertyTemplate simplePropertyTemplate = new IfcSimplePropertyTemplate(db, "IsExternal") { GlobalId = "3Yss80qXKHuO00025QrE$V", PrimaryMeasureType = "IfcBoolean" }; IfcPropertySetTemplate psetTemplate = new IfcPropertySetTemplate("Pset_WallCommon", simplePropertyTemplate) { GlobalId = "2VWFE0qXKHuO00025QrE$V" }; IfcPropertySingleValue psv = new IfcPropertySingleValue(db, "IsExternal", new IfcBoolean(false)); IfcPropertySet pset = new IfcPropertySet("Pset_WallCommon", psv); new IfcRelDefinesByTemplate(pset, psetTemplate); new IfcRelAssociatesClassification(partionWalls, pset); DirectoryInfo di = Directory.GetParent(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)); di = Directory.GetParent(di.FullName); db.WriteFile(Path.Combine(di.FullName, "TestClassification.ifc")); }
/// <summary> /// Get the IfcPropertySingleValue value and unit associated with the value /// </summary> /// <param name="propertyList">List of IfcSimpleProperty</param> /// <param name="name">property name we want to extract</param> /// <returns></returns> public Interval GetPropertyValue(List <IfcSimpleProperty> propertyList, string name) { Interval result = new Interval() { Value = DEFAULT_STRING, Unit = DEFAULT_STRING }; IfcPropertySingleValue ifcPSValue = propertyList.OfType <IfcPropertySingleValue>().Where(psv => psv.Name == name).FirstOrDefault(); if (ifcPSValue != null) { result.Value = (!string.IsNullOrEmpty(ifcPSValue.NominalValue.ToString())) ? ifcPSValue.NominalValue.Value.ToString() : DEFAULT_STRING; result.Unit = (ifcPSValue.Unit != null) ? GetUnitName(ifcPSValue.Unit) : DEFAULT_STRING; } return(result); }
public static IfcPropertySingleValue GetExtendedSingleValue(this IfcMaterial material, IModel model, string pSetName, string propertyName) { IfcExtendedMaterialProperties pSet = GetExtendedProperties(material, model, pSetName); if (pSet == null) { return(null); } IfcPropertySingleValue result = pSet.ExtendedProperties.Where <IfcPropertySingleValue>(sv => sv.Name == propertyName).FirstOrDefault(); return(result); }
protected BbSingleProperty(string name, bool value) { Name = name; _ifcValue = new IfcValue(); var iValue = new IfcBoolean { Value = value }; _ifcValue.Value = iValue; _ifcPropertySingleValue = new IfcPropertySingleValue { Name = this.Name, NominalValue = _ifcValue, }; }
internal void checkProperty(IfcObjectDefinition obj, string psetName, string propertyName, bool permitType, HashSet <String> allowableStrings) { IfcPropertySingleValue propertySingleValue = null; if (!string.IsNullOrEmpty(psetName)) { IfcPropertySet propertySet = null; if (obj is IfcObject ifcObject) { propertySet = ifcObject.FindPropertySet(psetName, permitType) as IfcPropertySet; } else { propertySet = obj.FindPropertySet(psetName) as IfcPropertySet; } if (propertySet == null) { System.Diagnostics.Debug.WriteLine("Test Fail " + obj.GlobalId + " " + obj.Name + " missing pset " + psetName); return; } propertySingleValue = propertySet.FindProperty(propertyName) as IfcPropertySingleValue; } else { propertySingleValue = obj.FindProperty(propertyName) as IfcPropertySingleValue; } if (propertySingleValue == null) { System.Diagnostics.Debug.WriteLine("Test Fail " + obj.GlobalId + " " + obj.Name + " missing property " + propertyName); return; } if (propertySingleValue.NominalValue == null) { System.Diagnostics.Debug.WriteLine("Test Fail " + obj.GlobalId + " " + obj.Name + " property " + propertyName + " has no value!"); return; } if (allowableStrings.Count > 0) { string propertyValue = propertySingleValue.NominalValue.ValueString; if (!allowableStrings.Contains(propertyValue)) { System.Diagnostics.Debug.WriteLine("Test Fail " + obj.GlobalId + " " + obj.Name + " property " + propertyName + " has unacceptable value :" + propertyValue); return; } } }
private string CreatePropertySummary(IfcProduct product) { var summary = new StringBuilder(); foreach (var pSet in product.PropertySets) { foreach (var property in pSet.HasProperties) { IfcPropertySingleValue singleVal = property as IfcPropertySingleValue; if (singleVal == null) { continue; } summary.AppendLine(singleVal.Name.Value + ": " + singleVal.NominalValue.Value + " " + singleVal.Unit); } } return(summary.ToString()); }
protected BbSingleProperty(string name, double value, Type type) { Name = name; _ifcValue = new IfcValue(); var iValue = Activator.CreateInstance(type) as REAL; if (iValue == null) { throw new InvalidOperationException(); } iValue.Value = value; _ifcValue.Value = iValue; _ifcPropertySingleValue = new IfcPropertySingleValue { Name = this.Name, NominalValue = _ifcValue, }; }
bool HasPropertyLikeExternalTrue(IfcWall wall) { //get relations property IEnumerable <IfcRelDefinesByProperties> rels = wall.IsDefinedByProperties; foreach (var rel in rels) { //get property set IfcPropertySet pSet = rel.RelatingPropertyDefinition as IfcPropertySet; if (pSet == null) { continue; } foreach (IfcProperty prop in pSet.HasProperties) { //get properties IfcPropertySingleValue singleVal = prop as IfcPropertySingleValue; if (singleVal == null) { continue; } if (singleVal.Name == "Wall Function") { //check value of the property IfcValue val = singleVal.NominalValue; if (val.UnderlyingSystemType == typeof(int)) { if ((int)val.Value == 1) { return(true); } } else if (val.UnderlyingSystemType == typeof(int?)) { if ((int?)val.Value == 1) { return(true); } } } } } return(false); }
public static void DeleteExtendedSingleValue(this IfcMaterial material, IModel model, string pSetName, string propertyName) { IfcExtendedMaterialProperties pSet = GetExtendedProperties(material, model, pSetName); if (pSet == null) { return; } IfcPropertySingleValue singleValue = GetExtendedSingleValue(material, model, pSetName, propertyName); if (singleValue == null) { return; } singleValue.NominalValue = null; }
Color readIfcComplexPropertyColor(IfcComplexProperty complex_prop) { Color cor = new Color(1, 1, 1, 1); var vec_hasProperties = complex_prop.HasProperties; if (vec_hasProperties.Count < 3) { return(cor); } IfcPropertySingleValue[] values = new IfcPropertySingleValue[3]; values[0] = (IfcPropertySingleValue)complex_prop.HasProperties[0]; values[1] = (IfcPropertySingleValue)complex_prop.HasProperties[1]; values[2] = (IfcPropertySingleValue)complex_prop.HasProperties[2]; if (values[0] != null && values[1] != null && values[2] != null) { IfcValue v1 = values[0].NominalValue; IfcValue v2 = values[1].NominalValue; IfcValue v3 = values[2].NominalValue; if (v1 != null && v2 != null && v3 != null) { IfcInteger v1_int = (IfcInteger)v1; IfcInteger v2_int = (IfcInteger)v2; IfcInteger v3_int = (IfcInteger)v3; if (v1_int != null && v2_int != null && v3_int != null) { float r = (float)v1_int / 255.0f; float g = (float)v2_int / 255.0f; float b = (float)v3_int / 255.0f; if (r < 0.05f && g < 0.05f && b < 0.05f) { r = 0.1f; g = 0.12f; b = 0.15f; } cor.r = r; cor.g = g; cor.b = b; } } } return(cor); }
/// <summary> /// Get the Time unit and value for the passed in property /// </summary> /// <param name="typeObject">IfcTypeObject </param> /// <param name="psetName">Property Set Name to retrieve IfcPropertySet Object</param> /// <param name="propertyName">Property Name held in IfcPropertySingleValue object</param> /// <param name="psetValues">List of IfcPropertySingleValue filtered to attribute names we require</param> /// <returns>Dictionary holding unit and value e.g. Year, 2.0</returns> private Interval GetDurationUnitAndValue(IfcPropertySingleValue typeValue) { const string DefaultUnit = "Year"; // n/a is not acceptable, so create a valid default Interval result = new Interval() { Value = DEFAULT_NUMERIC, Unit = DefaultUnit }; // try to get the property from the Type first //IfcPropertySingleValue typeValue = typeObject.GetPropertySingleValue(psetName, propertyName); //// TODO: Check this logic //// if null then try and get from first instance of this type //if (typeValue == null) // typeValue = psetValues.Where(p => p.Name == propertyName).FirstOrDefault(); if (typeValue == null) { return(result); } //Get the unit type if (typeValue.Unit != null) { result.Unit = GetUnitName(typeValue.Unit); } //Get the time period value if ((typeValue.NominalValue != null) && (typeValue.NominalValue is IfcReal)) //if a number then we can calculate { double val = (double)typeValue.NominalValue.Value; result.Value = val.ToString(); } else if (typeValue.NominalValue != null) //no number value so just show value for passed in propName { result.Value = typeValue.NominalValue.Value.ToString(); } return(result); }
/// <summary> /// Get Formatted Start Date /// </summary> /// <param name="allPropertyValues"></param> /// <returns></returns> private string GetStartTime(IfcPropertySingleValue ifcPropertySingleValue) { string startData = ""; if ((ifcPropertySingleValue != null) && (ifcPropertySingleValue.NominalValue != null)) { startData = ifcPropertySingleValue.NominalValue.ToString(); } DateTime frmDate; if (DateTime.TryParse(startData, out frmDate)) { startData = frmDate.ToString(Constants.DATE_FORMAT); } else { startData = Constants.DEFAULT_STRING; //Context.RunDate;//default is Now } return(startData); }
public static IfcValue GetExtendedSingleValueValue(this IfcMaterial material, IModel model, string pSetName, string propertyName) { IfcExtendedMaterialProperties pSet = GetExtendedProperties(material, model, pSetName); if (pSet == null) { return(null); } IfcPropertySingleValue singleValue = GetExtendedSingleValue(material, model, pSetName, propertyName); if (singleValue == null) { return(null); } IfcValue result = singleValue.NominalValue; return(result); }
public void CanDeserializeNestedStructure() { Entity[] Items = DeserializeAssertISO10303AndExtractItems(Utilities.StepNestedObjectsString()); Assert.AreEqual(1, Items.Length); Entity e = Items[0]; Assert.IsNotNull(e); IfcPropertySingleValue psv = e as IfcPropertySingleValue; Assert.IsNotNull(psv); Assert.AreEqual("Reference", psv.Name); Assert.AreEqual("Reference", psv.Description); Assert.IsNotNull(psv.NominalValue); Assert.IsNotNull(psv.NominalValue.Item); IfcText1 valueText = psv.NominalValue.Item as IfcText1; Assert.IsNotNull(valueText); Assert.IsNotNull(valueText.Value); Assert.AreEqual("foobar", valueText.Value); Assert.IsNull(psv.Unit); }
protected BbSingleProperty(string name, bool value) { Name = name; _ifcValue = new IfcValue(); var iValue = new IfcBoolean {Value = value}; _ifcValue.Value = iValue; _ifcPropertySingleValue = new IfcPropertySingleValue { Name = this.Name, NominalValue = _ifcValue, }; }