/// <summary>
        /// Get the property value where the property name equals the passed in value.
        /// Always use SetAllPropertyValues before calling this method
        /// </summary>
        /// <param name="propertyName">IfcProperty name</param>
        /// <param name="containsString">Do Contains text match on PropertyName if true, exact match if false</param>
        /// <returns></returns>
        public string GetPropertyValue(string propertyName, bool containsString)
        {
            IIfcSimpleProperty ifcProperty = null;

            if (containsString)
            {
                ifcProperty = ObjProperties.Where(p => p.Name.ToString().Contains(propertyName)).FirstOrDefault();
            }
            else
            {
                ifcProperty = ObjProperties.Where(p => p.Name == propertyName).FirstOrDefault();
            }

            if (ifcProperty == null)
            {
                return(Constants.DEFAULT_STRING);
            }

            //return a string value
            if (ifcProperty is IIfcPropertySingleValue singleValue)
            {
                if (singleValue.NominalValue != null &&
                    singleValue.NominalValue.Value != null)
                {
                    return(singleValue.NominalValue.Value.ToString());
                }
            }
            else if (ifcProperty is IIfcPropertyEnumeratedValue enumValue)
            {
                if (enumValue.EnumerationValues != null &&
                    enumValue.EnumerationValues.FirstOrDefault() != null &&
                    enumValue.EnumerationValues.FirstOrDefault().Value != null)
                {
                    return(enumValue.EnumerationValues.FirstOrDefault().Value.ToString());
                }
            }
            else if (ifcProperty is IfcPropertyReferenceValue propReference) //does not work with IFC4 interfaces!
            {
                IfcObjectReferenceSelect referenceSelect = propReference.PropertyReference;
                if (referenceSelect != null)
                {
                    string value = referenceSelect.ToString();
                    return(value);
                }
            }
            else
            {
                logger.LogWarning("GetPropertyValue is not implemented for {propertyType}", ifcProperty.GetType().Name);
            }

            return(Constants.DEFAULT_STRING);
        }
        public override void IfcParse(int propIndex, IPropertyValue value)
        {
            switch (propIndex)
            {
            case 0:
            case 1:
                base.IfcParse(propIndex, value);
                break;

            case 2:
                _usageName = value.StringVal;
                break;

            case 3:
                _propertyReference = (IfcObjectReferenceSelect)value.EntityVal;
                break;

            default:
                this.HandleUnexpectedAttribute(propIndex, value); break;
            }
        }
        public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
        {
            switch (propIndex)
            {
            case 0:
            case 1:
                base.Parse(propIndex, value, nestedIndex);
                return;

            case 2:
                _usageName = value.StringVal;
                return;

            case 3:
                _propertyReference = (IfcObjectReferenceSelect)(value.EntityVal);
                return;

            default:
                throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper()));
            }
        }
示例#4
0
 public IfcPropertyReferenceValue(IfcIdentifier __Name, IfcText?__Description, IfcText?__UsageName, IfcObjectReferenceSelect __PropertyReference)
     : base(__Name, __Description)
 {
     this._UsageName         = __UsageName;
     this._PropertyReference = __PropertyReference;
 }
        public static string GetValuesAsString(this IfcObjectReferenceSelect ifcObjectReferenceSelect)
        {
            var material = ifcObjectReferenceSelect as IfcMaterial;

            if (material != null)
            {
                return(material.Name.ToString());
            }
            var person = ifcObjectReferenceSelect as IfcPerson;

            if (person != null)
            {
                return(person.GetFullName());
            }
            var time = ifcObjectReferenceSelect as IfcDateAndTime;

            if (time != null)
            {
                return(time.AsString());
            }

            var list = ifcObjectReferenceSelect as IfcMaterialList;

            if (list != null)
            {
                List <string> values = list.Materials.Select(item => item.Name.ToString()).ToList();
                return(values.Count > 0 ? string.Join(", ", values) : string.Empty);
            }
            var @select = ifcObjectReferenceSelect as IfcOrganization;

            if (@select != null)
            {
                return(@select.Name.ToString());
            }
            var date = ifcObjectReferenceSelect as IfcCalendarDate;

            if (date != null)
            {
                return(date.AsString());
            }
            var localTime = ifcObjectReferenceSelect as IfcLocalTime;

            if (localTime != null)
            {
                return(localTime.AsString());
            }
            var organization = ifcObjectReferenceSelect as IfcPersonAndOrganization;

            if (organization != null)
            {
                IfcPersonAndOrganization ifcPersonAndOrganization = organization;
                string value = ifcPersonAndOrganization.ThePerson.GetFullName();
                value  = value.Trim();
                value += ", " + ifcPersonAndOrganization.TheOrganization.Name.ToString();
                return(value);
            }
            var layer = ifcObjectReferenceSelect as IfcMaterialLayer;

            if (layer != null)
            {
                IfcMaterialLayer ifcMaterialLayer = layer;
                string           value            = string.Empty;
                if (ifcMaterialLayer.Material != null)
                {
                    value += ifcMaterialLayer.Material.Name.ToString();
                }
                if (string.IsNullOrEmpty(value))
                {
                    value = ifcMaterialLayer.LayerThickness.Value.ToString();
                }
                else
                {
                    value += "(" + ifcMaterialLayer.LayerThickness.Value + ")";
                }
                return(value);
            }
            var reference = ifcObjectReferenceSelect as IfcExternalReference;

            if (reference != null)
            {
                if (reference.Location.HasValue)
                {
                    return(reference.Location.ToString());
                }
                return(string.Empty);
            }
            var series = ifcObjectReferenceSelect as IfcTimeSeries;

            if (series != null)
            {
                return(series.GetAsString());
            }
            var address = ifcObjectReferenceSelect as IfcAddress;

            if (address != null)
            {
                return(address.GetAsString());
            }
            var appliedValue = ifcObjectReferenceSelect as IfcAppliedValue;

            if (appliedValue != null)
            {
                return(appliedValue.AsString());
            }

            return(string.Empty);
        }
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     switch (propIndex)
     {
         case 0:
         case 1:
             base.IfcParse(propIndex, value);
             break;
         case 2:
             _usageName = value.StringVal;
             break;
         case 3:
             _propertyReference = (IfcObjectReferenceSelect) value.EntityVal;
             break;
         default:
             this.HandleUnexpectedAttribute(propIndex, value); break;
     }
 }
示例#7
0
        public static string GetValuesAsString(this IfcObjectReferenceSelect ifcObjectReferenceSelect)
        {
            if (ifcObjectReferenceSelect is IfcMaterial)
            {
                return((ifcObjectReferenceSelect as IfcMaterial).Name.ToString());
            }
            if (ifcObjectReferenceSelect is IfcPerson)
            {
                return((ifcObjectReferenceSelect as IfcPerson).GetFullName());
            }
            if (ifcObjectReferenceSelect is IfcDateAndTime)
            {
                return((ifcObjectReferenceSelect as IfcDateAndTime).GetAsString());
            }
            if (ifcObjectReferenceSelect is IfcMaterialList)
            {
                List <string> values = new List <string>();
                foreach (var item in (ifcObjectReferenceSelect as IfcMaterialList).Materials)
                {
                    values.Add(item.Name.ToString());
                }
                if (values.Count > 0)
                {
                    return(string.Join(", ", values));
                }
                else
                {
                    return(string.Empty);
                }
            }
            if (ifcObjectReferenceSelect is IfcOrganization)
            {
                return((ifcObjectReferenceSelect as IfcOrganization).Name.ToString());
            }
            if (ifcObjectReferenceSelect is IfcCalendarDate)
            {
                return((ifcObjectReferenceSelect as IfcCalendarDate).GetAsString());
            }
            if (ifcObjectReferenceSelect is IfcLocalTime)
            {
                return((ifcObjectReferenceSelect as IfcLocalTime).GetAsString());
            }
            if (ifcObjectReferenceSelect is IfcPersonAndOrganization)
            {
                IfcPersonAndOrganization ifcPersonAndOrganization = (ifcObjectReferenceSelect as IfcPersonAndOrganization);
                string value = ifcPersonAndOrganization.ThePerson.GetFullName();
                value  = value.Trim();
                value += ", " + ifcPersonAndOrganization.TheOrganization.Name.ToString();
                return(value);
            }
            if (ifcObjectReferenceSelect is IfcMaterialLayer)
            {
                IfcMaterialLayer ifcMaterialLayer = (ifcObjectReferenceSelect as IfcMaterialLayer);
                string           value            = string.Empty;
                if (ifcMaterialLayer.Material != null)
                {
                    value += ifcMaterialLayer.Material.Name.ToString();
                }
                if (string.IsNullOrEmpty(value))
                {
                    value = ifcMaterialLayer.LayerThickness.Value.ToString();
                }
                else
                {
                    value += "(" + ifcMaterialLayer.LayerThickness.Value.ToString() + ")";
                }
                return(value);
            }
            if (ifcObjectReferenceSelect is IfcExternalReference)
            {
                IfcExternalReference ifcExternalReference = (ifcObjectReferenceSelect as IfcExternalReference);
                if (ifcExternalReference.Location.HasValue)
                {
                    return(ifcExternalReference.Location.ToString());
                }
                return(string.Empty);
            }
            if (ifcObjectReferenceSelect is IfcTimeSeries)
            {
                return((ifcObjectReferenceSelect as IfcTimeSeries).GetAsString());
            }
            if (ifcObjectReferenceSelect is IfcAddress)
            {
                return((ifcObjectReferenceSelect as IfcAddress).GetAsString());
            }
            if (ifcObjectReferenceSelect is IfcAppliedValue)
            {
                return((ifcObjectReferenceSelect as IfcAppliedValue).GetAsString());
            }

            return(string.Empty);
        }