Ejemplo n.º 1
0
        /// <summary>
        /// Adds an element type to the object if it doesn't already have one, return the new or existing relationship that holds the type and this element. If there is a relationship for this type but this element is not related it adds it to the exosting relationship
        /// </summary>
        /// <param name="theType"></param>
        /// <returns></returns>
        public IfcRelDefinesByType AddDefiningType(IfcTypeObject theType)
        {
            var typedefs    = Model.Instances.Where <IfcRelDefinesByType>(r => r.RelatingType == theType).ToList();
            var thisTypeDef = typedefs.FirstOrDefault(r => r.RelatedObjects.Contains((this)));

            if (thisTypeDef != null)
            {
                return(thisTypeDef);                    // it is already type related
            }
            var anyTypeDef = typedefs.FirstOrDefault(); //take any one of the rels of the type

            if (anyTypeDef != null)
            {
                anyTypeDef.RelatedObjects.Add(this);
                return(anyTypeDef);
            }
            var newdef = Model.Instances.New <IfcRelDefinesByType>(); //create one

            newdef.RelatedObjects.Add(this);
            newdef.RelatingType = theType;
            return(newdef);
        }
Ejemplo n.º 2
0
        public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
        {
            switch (propIndex)
            {
            case 0:
            case 1:
            case 2:
            case 3:
                base.Parse(propIndex, value, nestedIndex);
                return;

            case 4:
                _relatedObjects.InternalAdd((IfcObject)value.EntityVal);
                return;

            case 5:
                _relatingType = (IfcTypeObject)(value.EntityVal);
                return;

            default:
                throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper()));
            }
        }