示例#1
0
        public AttributeType[] GetAttributes(IfcObjectDefinition ifcObjectDefinition)
        {
            XbimAttributedObject attributedObject;

            if (_attributedObjects.TryGetValue(ifcObjectDefinition, out attributedObject))
            {
                var properties    = attributedObject.Properties.Where(kv => !_cobieProperties.Contains(kv.Key)); //exclude the properties we have written as COBie value
                var keyValuePairs = properties as KeyValuePair <string, IfcProperty>[] ?? properties.ToArray();
                if (keyValuePairs.Length > 0)
                {
                    var attributeCollection = new AttributeType[keyValuePairs.Length];
                    for (int i = 0; i < keyValuePairs.Length; i++)
                    {
                        var property      = keyValuePairs[i].Value;
                        var splitName     = keyValuePairs[i].Key.Split('.');
                        var pSetName      = splitName[0];
                        var attributeType = XbimAttributedObject.ConvertToAttributeType(property);
                        attributeType.propertySetName = pSetName;
                        //var pSetDef = attributedObject.GetPropertySetDefinition(pSetName);
                        //if (pSetDef != null)
                        //    attributeType.externalID = ExternalEntityIdentity(pSetDef);
                        attributeCollection[i] = attributeType;
                    }
                    return(attributeCollection);
                }
            }
            return(null);
        }
示例#2
0
        private void GetPropertySets()
        {
            _attributedObjects = new Dictionary <IfcObjectDefinition, XbimAttributedObject>();
            var relProps = _model.Instances.OfType <IfcRelDefinesByProperties>().ToList();

            foreach (var relProp in relProps)
            {
                foreach (var ifcObject in relProp.RelatedObjects)
                {
                    XbimAttributedObject attributedObject;
                    if (!_attributedObjects.TryGetValue(ifcObject, out attributedObject))
                    {
                        attributedObject = new XbimAttributedObject(ifcObject);
                        _attributedObjects.Add(ifcObject, attributedObject);
                    }
                    attributedObject.AddPropertySetDefinition(relProp.RelatingPropertyDefinition);
                }
            }
            foreach (var typeObject in _definingTypeObjectMap.Keys)
            {
                XbimAttributedObject attributedObject;
                if (!_attributedObjects.TryGetValue(typeObject, out attributedObject))
                {
                    attributedObject = new XbimAttributedObject(typeObject);
                    _attributedObjects.Add(typeObject, attributedObject);
                }
                if (typeObject.HasPropertySets != null)
                {
                    foreach (var pset in typeObject.HasPropertySets)
                    {
                        attributedObject.AddPropertySetDefinition(pset);
                    }
                }
            }
        }