示例#1
0
 protected BbMainPiece(BbAssembly assembly, IfcElement element, IfcRelAggregates ifcRelAggregates)
 {
     //BbAssembly = assembly;
     // wrong implementation need modification, donghoon 20131205
     //_ifcElement = element;
     //_ifcRelAggregates = ifcRelAggregates;
 }
示例#2
0
        /// <summary>
        ///   Returns the Element that contains the void that this element fills, null if this is not a void filler
        ///   i.e. will return the wall that contains this door
        /// </summary>
        /// <param name = "elem"></param>
        /// <returns></returns>
        public static IfcElement GetFilledElement(this IfcElement elem, IModel model)
        {
            IfcRelFillsElement rel =
                model.Instances.Where <IfcRelFillsElement>(r => r.RelatedBuildingElement == elem).FirstOrDefault();

            return(rel != null?rel.RelatingOpeningElement.GetFeatureElement(model) : null);
        }
示例#3
0
        //        ExtrudedElement(
        //            string name,
        //            Profile profile,
        //            double length,
        //            Coordinate3D position,
        //            Direction3D zAxis,
        //            Direction3D xAxis,
        //            Direction3D extrudeDirection,
        //            Element container)
        //            :this (name, profile, length, position, zAxis, xAxis, extrudeDirection,
        //                   container.ObjectLocalPlacement, container.IfcElement.OwnerHistory)
        //        {}
        //
        //        ExtrudedElement(
        //            string name,
        //            Profile profile,
        //            double length,
        //            Coordinate3D position,
        //            Direction3D zAxis,
        //            Direction3D xAxis,
        //            Direction3D extrudeDirection,
        //            SpatialElement container)
        //            :this (name, profile, length, position, zAxis, xAxis, extrudeDirection,
        //                   container.ObjectLocalPlacement, container.IfcSpatialStructureElement.OwnerHistory)
        //        {}
        BbExtrudedElement(
			string name,
			BbProfile profile,
			double length,
			BbCoordinate3D position,
			BbDirection3D zAxis,
			BbDirection3D xAxis,
			BbDirection3D extrudeDirection,
			BbLocalPlacement3D containerLocation,
			IfcOwnerHistory ownerHistory,
			Type ifcEntityType)
        {
            Name = name;
            Profile = profile;
            Length = length;
            BbPosition3D pos = BbPosition3D.Create(position, zAxis, xAxis);

            ObjectBbLocalPlacement = BbLocalPlacement3D.Create(
                containerLocation, pos	);

            BbExtrudedGeometry bbExtrudedGeometry = BbExtrudedGeometry.Create(
                profile,
                BbHeaderSetting.Setting3D.DefaultBbPosition3D,
                BbHeaderSetting.Setting3D.ZAxis,
                Length);

            _ifcElement = Activator.CreateInstance(ifcEntityType) as IfcElement;
            _ifcElement.GlobalId = IfcGloballyUniqueId.NewGuid();
            _ifcElement.OwnerHistory = ownerHistory;
            _ifcElement.Name = Name;
                //ObjectType = ,
            _ifcElement.ObjectPlacement = ObjectBbLocalPlacement.IfcLocalPlacement;
            _ifcElement.Representation = bbExtrudedGeometry.IfcProductDefinitionShape;
        }
示例#4
0
            private List <IfcElement> createRes(List <IntPtr> elements, string propertyName, string propertyValue)
            {
                List <IfcElement> result = new List <IfcElement>();

                foreach (var element in elements)
                {
                    IfcElement ifcElement = new IfcElement();

                    ifcElement.name = getAttrValueAsString(element, "Name");
                    ifcElement.guid = getAttrValueAsString(element, "GlobalId");
                    switch (propertyName)
                    {
                    case NETVOLUME:
                        ifcElement.volume = propertyValue;
                        break;

                    case "Weight":
                        ifcElement.weight = propertyValue;
                        break;

                    case "Material":
                        ifcElement.material = propertyValue;
                        break;

                    case "Profile":
                        ifcElement.profile = propertyValue;
                        break;
                    }
                    result.Add(ifcElement);
                }
                return(result);
            }
示例#5
0
 protected BbMainPiece(BbAssembly assembly, IfcElement element, IfcRelAggregates ifcRelAggregates)
 {
     //BbAssembly = assembly;
     // wrong implementation need modification, donghoon 20131205
     //_ifcElement = element;
     //_ifcRelAggregates = ifcRelAggregates;
 }
//		ExtrudedElement(
//			string name,
//			Profile profile,
//			double length,
//			Coordinate3D position,
//			Direction3D zAxis,
//			Direction3D xAxis,
//			Direction3D extrudeDirection,
//			Element container)
//			:this (name, profile, length, position, zAxis, xAxis, extrudeDirection,
//			       container.ObjectLocalPlacement, container.IfcElement.OwnerHistory)
//		{}
//
//		ExtrudedElement(
//			string name,
//			Profile profile,
//			double length,
//			Coordinate3D position,
//			Direction3D zAxis,
//			Direction3D xAxis,
//			Direction3D extrudeDirection,
//			SpatialElement container)
//			:this (name, profile, length, position, zAxis, xAxis, extrudeDirection,
//			       container.ObjectLocalPlacement, container.IfcSpatialStructureElement.OwnerHistory)
//		{}

        BbExtrudedElement(
            string name,
            BbProfile profile,
            double length,
            BbCoordinate3D position,
            BbDirection3D zAxis,
            BbDirection3D xAxis,
            BbDirection3D extrudeDirection,
            BbLocalPlacement3D containerLocation,
            IfcOwnerHistory ownerHistory,
            Type ifcEntityType)
        {
            Name    = name;
            Profile = profile;
            Length  = length;
            BbPosition3D pos = BbPosition3D.Create(position, zAxis, xAxis);

            ObjectBbLocalPlacement = BbLocalPlacement3D.Create(
                containerLocation, pos);

            BbExtrudedGeometry bbExtrudedGeometry = BbExtrudedGeometry.Create(
                profile,
                BbHeaderSetting.Setting3D.DefaultBbPosition3D,
                BbHeaderSetting.Setting3D.ZAxis,
                Length);

            _ifcElement              = Activator.CreateInstance(ifcEntityType) as IfcElement;
            _ifcElement.GlobalId     = IfcGloballyUniqueId.NewGuid();
            _ifcElement.OwnerHistory = ownerHistory;
            _ifcElement.Name         = Name;
            //ObjectType = ,
            _ifcElement.ObjectPlacement = ObjectBbLocalPlacement.IfcLocalPlacement;
            _ifcElement.Representation  = bbExtrudedGeometry.IfcProductDefinitionShape;
        }
示例#7
0
        private BbPiece(string name, string objectType, BbProfile profile,
                        double length, BbCoordinate3D position, BbDirection3D zAxis,
                        BbDirection3D xAxis, BbDirection3D extrudeDirection,
                        BbLocalPlacement3D hostPlacement, Type ifcEntityType)
        {
            Length  = length;
            Profile = profile;
            var pos = BbPosition3D.Create(position, zAxis, xAxis);

            ObjectBbLocalPlacement = BbLocalPlacement3D.Create(
                hostPlacement, pos);

            var semExtrudedGeometry = BbExtrudedGeometry.Create(
                profile,
                BbHeaderSetting.Setting3D.DefaultBbPosition3D,
                extrudeDirection,
                Length);

            _ifcElement = Activator.CreateInstance(ifcEntityType) as IfcElement;
            if (_ifcElement == null)
            {
                return;
            }

            _ifcElement.GlobalId        = IfcGloballyUniqueId.ConvertToIfcGuid(Guid);
            _ifcElement.OwnerHistory    = BbHeaderSetting.Setting3D.IfcOwnerHistory;
            _ifcElement.Name            = name;
            _ifcElement.ObjectType      = objectType;
            _ifcElement.ObjectPlacement = ObjectBbLocalPlacement.IfcLocalPlacement;
            _ifcElement.Representation  = semExtrudedGeometry.IfcProductDefinitionShape;
            //_ifcElement.Tag = id;
        }
示例#8
0
        protected override void GenerateInstance(IfcBuilding building)
        {
            DatabaseIfc db    = building.Database;
            IfcBlock    block = new IfcBlock(new IfcAxis2Placement3D(new IfcCartesianPoint(db, 0, 0, 0)), 2000, 800, 800);
            IfcRoundedRectangleProfileDef roundedRectangle  = new IfcRoundedRectangleProfileDef(db, "VoidProfile", 1800, 600, 200);
            IfcExtrudedAreaSolid          extrudedAreaSolid = new IfcExtrudedAreaSolid(roundedRectangle, new IfcAxis2Placement3D(new IfcCartesianPoint(db, 1000, 400, 100)), new IfcDirection(db, 0, 0, 1), 700);
            IfcBooleanResult        booleanResult           = new IfcBooleanResult(IfcBooleanOperator.DIFFERENCE, block, extrudedAreaSolid);
            IfcCsgSolid             csgSolid             = new IfcCsgSolid(booleanResult);
            IfcRepresentationMap    representationMap    = new IfcRepresentationMap(csgSolid);
            IfcMaterial             ceramic              = new IfcMaterial(db, "Ceramic");
            IfcSanitaryTerminalType sanitaryTerminalType = new IfcSanitaryTerminalType(db, "Bath", IfcSanitaryTerminalTypeEnum.BATH)
            {
                MaterialSelect = ceramic
            };

            sanitaryTerminalType.RepresentationMaps.Add(representationMap);
            IfcElement element = sanitaryTerminalType.GenerateMappedItemElement(building, new IfcCartesianTransformationOperator3D(db));

            db.Context.AddDeclared(sanitaryTerminalType);

            //Unique ids assigned to generate constant IfcScript  sample files, remove otherwise
            sanitaryTerminalType.GlobalId = "1HarmwaPv3OeJSXpaoPKpg";
            ceramic.Associates.GlobalId   = "0Pkhszwjv1qRMYyCFg9fjB";
            sanitaryTerminalType.ObjectTypeOf.GlobalId = "1lO$X3e3j9lfVMhNy4MzKB";
            element.GlobalId = "3$$o7C03j0KQeLnoj018fc";
        }
示例#9
0
        internal static void AttchOpening(this IfcElement element, IfcStore model, IfcOpeningElement opening)
        {
            IfcRelVoidsElement relVoids = model.Instances.New <IfcRelVoidsElement>();

            relVoids.RelatedOpeningElement   = opening;
            relVoids.RelatingBuildingElement = element;
        }
示例#10
0
        BbBrepElement(
            string name,
            BbBRepGeometry brepGeometry,
            BbCoordinate3D position,
            BbDirection3D zAxis,
            BbDirection3D xAxis,
            BbLocalPlacement3D containerLocation,
            IfcOwnerHistory ownerHistory,
            Type IfcEntityType)
        {
            Name = name;
            //Profile = profile;
            BbPosition3D pos = BbPosition3D.Create(position, zAxis, xAxis);

            ObjectBbLocalPlacement = BbLocalPlacement3D.Create(
                containerLocation, pos	);

            //			ifcBuildingElement = Activator.CreateInstance(EbConstants.Part21NSName, EbConstants.Part21NSName + "." + ifcEntityName);
            ifcElement = Activator.CreateInstance(IfcEntityType) as IfcElement;

            ifcElement.GlobalId = IfcGloballyUniqueId.NewGuid();
            ifcElement.OwnerHistory = ownerHistory;
            ifcElement.Name = Name;
            //ObjectType = ,
            ifcElement.ObjectPlacement = ObjectBbLocalPlacement.IfcLocalPlacement;
            ifcElement.Representation = brepGeometry.IfcProductDefinitionShape;
        }
示例#11
0
        BbBrepElement(
            string name,
            BbBRepGeometry brepGeometry,
            BbCoordinate3D position,
            BbDirection3D zAxis,
            BbDirection3D xAxis,
            BbLocalPlacement3D containerLocation,
            IfcOwnerHistory ownerHistory,
            Type IfcEntityType)
        {
            Name = name;
            //Profile = profile;
            BbPosition3D pos = BbPosition3D.Create(position, zAxis, xAxis);

            ObjectBbLocalPlacement = BbLocalPlacement3D.Create(
                containerLocation, pos);



//			ifcBuildingElement = Activator.CreateInstance(EbConstants.Part21NSName, EbConstants.Part21NSName + "." + ifcEntityName);
            ifcElement = Activator.CreateInstance(IfcEntityType) as IfcElement;

            ifcElement.GlobalId     = IfcGloballyUniqueId.NewGuid();
            ifcElement.OwnerHistory = ownerHistory;
            ifcElement.Name         = Name;
            //ObjectType = ,
            ifcElement.ObjectPlacement = ObjectBbLocalPlacement.IfcLocalPlacement;
            ifcElement.Representation  = brepGeometry.IfcProductDefinitionShape;
        }
示例#12
0
        public static bool HasBoundingElement(this IfcSpace space, IModel model, IfcElement element)
        {
            IfcRelSpaceBoundary relation =
                model.Instances.Where <IfcRelSpaceBoundary>(
                    rel => rel.RelatingSpace == space && rel.RelatedBuildingElement == element).FirstOrDefault();

            return(relation != null);
        }
        /// <summary>
        /// Add element relationship to a parent object
        /// </summary>
        /// <param name="ifcElement">IfcElement object</param>
        /// <param name="spaceNames">Name used as key to find parent object</param>
        private void AddElementRelationship(IfcElement ifcElement, string spaceNames)
        {
            spaceNames = spaceNames.ToLower().Trim();
            IfcSpace          ifcSpace          = null;
            IfcBuildingStorey ifcBuildingStorey = null;

            //see if the full name is in spaces
            ifcSpace = IfcSpaces.Where(space => space.Name.ToString().ToLower().Trim() == spaceNames).FirstOrDefault();
            if (ifcSpace != null)
            {
                ifcSpace.AddElement(ifcElement);
            }
            else //not in spaces so try Floors
            {
                ifcBuildingStorey = IfcBuildingStoreys.Where(bs => bs.Name.ToString().ToLower().Trim() == spaceNames).FirstOrDefault();
                if (ifcBuildingStorey != null)
                {
                    ifcBuildingStorey.AddElement(ifcElement);
                }
                else //not in floors so see if the space names is a delimited list
                {
                    var splitKey   = GetSplitChar(spaceNames);
                    var spaceArray = spaceNames.Split(splitKey);
                    if (spaceArray.Count() > 1) //if one we have already tried above, if more than one then try each item
                    {
                        foreach (var spaceitem in spaceArray)
                        {
                            var spaceName = spaceitem.Trim();
                            ifcSpace = IfcSpaces.Where(space => space.Name.ToString().ToLower().Trim() == spaceName).FirstOrDefault();
                            if (ifcSpace != null)
                            {
                                ifcSpace.AddElement(ifcElement);
                            }
                            else
                            {
                                ifcBuildingStorey = IfcBuildingStoreys.Where(bs => bs.Name.ToString().ToLower().Trim() == spaceName).FirstOrDefault();
                                if (ifcBuildingStorey != null)
                                {
                                    ifcBuildingStorey.AddElement(ifcElement);
                                }
                                else
                                {
                                    GetBuilding().AddElement(ifcElement); //default to building, probably give incorrect bounding box as we do not know what the element parent was
                                }
                            }
                        }
                    }
                    else
                    {
                        GetBuilding().AddElement(ifcElement); //default to building, probably give incorrect bounding box as we do not know what the element parent was
                    }
                }
            }
        }
示例#14
0
        internal ObjectIfcProperties(IfcElement element)
        {
            bool readOnly = true;

            Add(new CustomProperty("GlobalId", element.GlobalId, typeof(string), true, true)
            {
                Group = "Element"
            });
            Add(new CustomProperty("Name", element.Name, typeof(string), readOnly, true)
            {
                Group = "Element"
            });
            Add(new CustomProperty("Description", element.Description, typeof(string), readOnly, true)
            {
                Group = "Element"
            });
            Add(new CustomProperty("ObjectType", element.ObjectType, typeof(string), readOnly, true)
            {
                Group = "Element"
            });
            Add(new CustomProperty("Type", element.GetType().Name, typeof(string), true, true)
            {
                Group = "Element"
            });
            Add(new CustomProperty("Tag", element.Tag, typeof(string), readOnly, true)
            {
                Group = "Element"
            });

            foreach (IfcPropertySet pset in element.IsDefinedBy.ToList().ConvertAll(x => x.RelatingPropertyDefinition).OfType <IfcPropertySet>())
            {
                foreach (IfcPropertySingleValue psv in pset.HasProperties.Values.ToList().OfType <IfcPropertySingleValue>())
                {
                    IfcValue val = psv.NominalValue;
                    if (val == null)
                    {
                        Add(new CustomProperty(psv.Name, "", typeof(string), readOnly, true)
                        {
                            Group = pset.Name
                        });
                    }
                    else
                    {
                        Object obj = val.Value;
                        Add(new CustomProperty(psv.Name, obj, obj.GetType(), readOnly, true)
                        {
                            Group = pset.Name
                        });
                    }
                }
            }
        }
 /// <summary>
 /// Get Description for passed in IfcElement
 /// </summary>
 /// <param name="el">Element holding description</param>
 /// <returns>string</returns>
 internal string GetComponentDescription(IfcElement el)
 {
     if (el != null)
     {
         if (!string.IsNullOrEmpty(el.Description))
         {
             return(el.Description);
         }
         else if (!string.IsNullOrEmpty(el.Name))
         {
             return(el.Name);
         }
     }
     return(DEFAULT_STRING);
 }
示例#16
0
        internal ElementIfcProperties(IfcElement element) : base(element)
        {
            string keyword  = element.KeyWord;
            bool   readOnly = true;

            Add(new CustomProperty("ObjectType", element.ObjectType, typeof(string), readOnly, true)
            {
                Group = keyword
            });
            Add(new CustomProperty("Type", element.GetType().Name, typeof(string), true, true)
            {
                Group = keyword
            });
            Add(new CustomProperty("Tag", element.Tag, typeof(string), readOnly, true)
            {
                Group = keyword
            });

            IfcElementType elementType = element.RelatingType as IfcElementType;

            if (elementType != null)
            {
                List.Add(new ElementTypeIfcProperties(elementType));
            }
            foreach (IfcPropertySet pset in element.IsDefinedBy.ToList().ConvertAll(x => x.RelatingPropertyDefinition).OfType <IfcPropertySet>())
            {
                foreach (IfcPropertySingleValue psv in pset.HasProperties.Values.ToList().OfType <IfcPropertySingleValue>())
                {
                    IfcValue val = psv.NominalValue;
                    if (val == null)
                    {
                        Add(new CustomProperty(psv.Name, "", typeof(string), readOnly, true)
                        {
                            Group = pset.Name
                        });
                    }
                    else
                    {
                        Object obj = val.Value;
                        Add(new CustomProperty(psv.Name, obj, obj.GetType(), readOnly, true)
                        {
                            Group = pset.Name
                        });
                    }
                }
            }
        }
示例#17
0
        /// <summary>
        /// Get Space name which holds the passed in IfcElement
        /// </summary>
        /// <param name="el">Element to extract space name from</param>
        /// <param name="Model"></param>
        /// <param name="SpaceBoundingBoxInfo"></param>
        /// <param name="Context"></param>
        /// <returns>string</returns>
        internal static string GetComponentRelatedSpace(IfcElement el, IfcStore Model, IEnumerable <SpaceInfo> SpaceBoundingBoxInfo, COBieContext Context)
        {
            string        value = "";
            List <string> names = new List <string>();

            if (el != null)                                                                                           //&& el.ContainedInStructure.Count() > 0
            {
                var owningObjects = el.ContainedInStructure.Select(cis => cis.RelatingStructure).OfType <IfcSpace>(); //only one or zero held in ContainedInStructure
                foreach (IfcSpace item in owningObjects)
                {
                    if (item.Name != null)
                    {
                        names.Add(item.Name);
                    }
                }
            }

            //check for the element as a containing item of a space
            if (ifcRelSpaceBoundarys == null)
            {
                ifcRelSpaceBoundarys = Model.FederatedInstances.OfType <IfcRelSpaceBoundary>().Where(rsb => (rsb.RelatedBuildingElement != null)).ToList();
            }
            var ifcSpaces = ifcRelSpaceBoundarys.Where(rsb => rsb.RelatedBuildingElement == el).Select(rsb => rsb.RelatingSpace);

            foreach (IfcSpace item in ifcSpaces)
            {
                if ((item.Name != null) && (!names.Contains(item.Name)))
                {
                    names.Add(item.Name);
                }
            }

            if (names.Count > 0) //check we have some values
            {
                value = string.Join(", ", names);
            }

            //if no space is saved with the element then get from the geometry
            if (string.IsNullOrEmpty(value))
            {
                value = GetSpaceHoldingElement(el, Model, SpaceBoundingBoxInfo, ifcSpaces, Context);
            }


            return(string.IsNullOrEmpty(value) ? Constants.DEFAULT_STRING : value);
        }
        private IEnumerable <IfcProduct> GetProductsInProduct(IfcProduct prod)
        {
            //decomposes is a supertype of IfcRelAggregates, IfcRelNests
            IEnumerable <IfcRelDecomposes> decompRels = _model.Instances.Where <IfcRelDecomposes>(r => r.RelatingObject == prod);

            foreach (var item in decompRels)
            {
                foreach (var p in item.RelatedObjects)
                {
                    IfcProduct product = p as IfcProduct;
                    yield return(product);
                }
            }

            //fills
            IfcOpeningElement opening = prod as IfcOpeningElement;

            if (opening != null)
            {
                IEnumerable <IfcRelFillsElement> fillsRels = _model.Instances.Where <IfcRelFillsElement>(r => r.RelatingOpeningElement == opening);
                foreach (var rel in fillsRels)
                {
                    yield return(rel.RelatedBuildingElement);
                }
            }

            //voids
            IfcElement element = prod as IfcElement;

            if (element != null)
            {
                IEnumerable <IfcRelVoidsElement> voidsRels = _model.Instances.Where <IfcRelVoidsElement>(r => r.RelatingBuildingElement == element);
                foreach (var rel in voidsRels)
                {
                    yield return(rel.RelatedOpeningElement);

                    //go one level deeper to the elements filling the opening because these are spatialy in the original product as well
                    foreach (var e in GetFillingProducts(rel.RelatedOpeningElement))
                    {
                        yield return(e);
                    }
                }
            }
        }
示例#19
0
            public static List <MaterialLib> ExtractMaterial(IfcElement ifcele)
            {
                var ifcmats             = ifcele.HasAssociations.Where(o => o is IfcRelAssociatesMaterial);
                List <MaterialLib> mats = new List <MaterialLib>();

                foreach (var ifcmat in ifcmats)
                {
                    ifcele.Database.Where(o => o == ifcmat).Cast <IfcRelAssociatesMaterial>().ForEach(x =>
                    {
                        if (x.RelatingMaterial is IfcMaterialLayerSetUsage)
                        {
                            var matusage = x.RelatingMaterial as IfcMaterialLayerSetUsage;
                            var c        = matusage.ForLayerSet.MaterialLayers.Count;
                            mats.AddRange(ExtractMaterialData(matusage));
                        }
                    });
                }
                return(mats);
            }
示例#20
0
            public static Core ExtractType(IfcElement ifcele)
            {
                IfcTypeObject ifctype = ifcele.IsTypedBy.RelatingType;
                FinishLib     flib    = new FinishLib();

                flib.FKey_Category = Category.GetorAddCategory(ifctype.Name.Split(':')[0]).GuId;
                ExtractTypicalProperties(ifctype, flib);
                flib.Name = ifctype.Name.Split(':')[1];

                var d = new Data("PreDefined ObjectType", ifctype.GetPredefinedType());

                flib.Additional_Info.Add(d);

                flib.Additional_Info.ForEach(dx =>
                {
                    dx.SetFkeyParent(flib);
                });

                return(flib);
            }
示例#21
0
        public static void AddBoundingElement(this IfcSpace space, IModel model, IfcElement element,
                                              IfcPhysicalOrVirtualEnum physicalOrVirtualBoundary,
                                              IfcInternalOrExternalEnum internalOrExternalBoundary)
        {
            //avoid adding element which is already defined as bounding element
            if (space.HasBoundingElement(model, element))
            {
                return;
            }

            IfcRelSpaceBoundary relation = model.Instances.New <IfcRelSpaceBoundary>(rel =>
            {
                rel.RelatingSpace = space;
                rel.InternalOrExternalBoundary =
                    internalOrExternalBoundary;
                rel.RelatedBuildingElement    = element;
                rel.PhysicalOrVirtualBoundary =
                    physicalOrVirtualBoundary;
            });
        }
        /// <summary>
        /// Creates a number in ifc geometry representing the element, the next number is incremented
        /// </summary>
        /// <param name="ifcElement"></param>
        /// <param name="index">The index of the element in the type collection</param>
        internal void CreateObjectGeometry(IfcElement ifcElement, int index)
        {
            var rectProfile = TargetRepository.Instances.New <IfcRectangleProfileDef>();
            var dims        = TargetRepository.ModelFactors.OneMilliMeter * 100;

            rectProfile.Position    = MakeAxis2Placement2D();
            rectProfile.XDim        = dims;
            rectProfile.YDim        = dims;
            rectProfile.ProfileType = IfcProfileTypeEnum.AREA;
            //extrude it
            var extrusion = TargetRepository.Instances.New <IfcExtrudedAreaSolid>();

            extrusion.Depth             = dims;
            extrusion.ExtrudedDirection = _downDirection;
            extrusion.Position          = MakeAxis2Placement3D();
            extrusion.SweptArea         = rectProfile;
            //locate it
            ifcElement.ObjectPlacement = MakeLocalPlacement(_assetTypeInfoTypeNumber * dims * 1.2, 0, index * dims * 1.2);
            ifcElement.Representation  = MakeSweptSolidRepresentation(extrusion);
        }
        public override void IfcParse(int propIndex, IPropertyValue value)
        {
            switch (propIndex)
            {
            case 0:
            case 1:
            case 2:
            case 3:
                base.IfcParse(propIndex, value);
                break;

            case 4:
                _relatingElement = (IfcElement)value.EntityVal;
                break;

            case 5:
                _relatedStructuralMember = (IfcStructuralMember)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:
            case 2:
            case 3:
                base.Parse(propIndex, value, nestedIndex);
                return;

            case 4:
                _relatingElement = (IfcElement)(value.EntityVal);
                return;

            case 5:
                _relatedStructuralMember = (IfcStructuralMember)(value.EntityVal);
                return;

            default:
                throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper()));
            }
        }
示例#25
0
文件: Bath.cs 项目: mccune/IfcScript
        protected override void GenerateData(STPModelData md, IfcBuilding building)
        {
            IfcBlock block = new IfcBlock(md, Plane.WorldXY, 2000, 800, 800);
            IfcRoundedRectangleProfileDef roundedRectangle  = new IfcRoundedRectangleProfileDef(md, "VoidProfile", 600, 1800, 200);
            IfcExtrudedAreaSolid          extrudedAreaSolid = new IfcExtrudedAreaSolid(roundedRectangle, new IfcAxis2Placement3D(md, new Plane(new Point3d(1000, 400, 100), Vector3d.XAxis, Vector3d.YAxis)), new IfcDirection(md, 0, 0, 1), 700);
            IfcBooleanResult     booleanResult     = new IfcBooleanResult(IfcBooleanOperator.DIFFERENCE, block, extrudedAreaSolid);
            IfcCsgSolid          csgSolid          = new IfcCsgSolid(booleanResult);
            IfcRepresentationMap representationMap = new IfcRepresentationMap(csgSolid);
            IfcMaterial          ceramic           = new IfcMaterial(md, "Ceramic", "", "");

            ceramic.Associates.GlobalId = "0Pkhszwjv1qRMYyCFg9fjB";
            IfcSanitaryTerminalType sanitaryTerminalType = new IfcSanitaryTerminalType(md, "Bath", IfcSanitaryTerminalTypeEnum.BATH)
            {
                GlobalId = "1HarmwaPv3OeJSXpaoPKpg", MaterialSelect = ceramic, RepresentationMaps = new List <IfcRepresentationMap>()
                {
                    representationMap
                }
            };

            sanitaryTerminalType.ObjectTypeOf.GlobalId = "1lO$X3e3j9lfVMhNy4MzKB";
            IfcElement element = sanitaryTerminalType.GenerateMappedItemElement(building, Plane.WorldXY);

            element.GlobalId = "3$$o7C03j0KQeLnoj018fc";
        }
        /// <summary>
        /// Create an instance of an object via a string name
        /// </summary>
        /// <param name="elementTypeName">String holding object type name we eant to create</param>
        /// <param name="model">Model object</param>
        /// <returns></returns>
        public static IfcElement GetElementInstance(string elementTypeName, IModel model)
        {
            elementTypeName = elementTypeName.Trim().ToUpper();
            ExpressType ifcType;
            IfcElement  ifcElement = null;

            if (model.Metadata.TryGetExpressType(elementTypeName, out ifcType))
            {
                var method  = typeof(IEntityCollection).GetMethod("New", Type.EmptyTypes);
                var generic = method.MakeGenericMethod(ifcType.Type);
                var eleObj  = generic.Invoke(model.Instances, null);
                if (eleObj is IfcElement)
                {
                    ifcElement = (IfcElement)eleObj;
                }
            }


            if (ifcElement == null)
            {
                ifcElement = model.Instances.New <IfcFurnishingElement>(); //was IfcVirtualElement, but this is excluded in the import filters, so just using
            }
            return(ifcElement);
        }
示例#27
0
            static List <Data> ExtractData(IfcElement ifcele, Core model)
            {
                var props = ((IfcPropertySet)ifcele.IsDefinedBy.First().RelatingPropertyDefinition).HasProperties;

                return(IfcData.ExtractProps(props, model));
            }
示例#28
0
 public IfcRelConnectsPathElements(IfcGloballyUniqueId __GlobalId, IfcOwnerHistory __OwnerHistory, IfcLabel?__Name, IfcText?__Description, IfcConnectionGeometry __ConnectionGeometry, IfcElement __RelatingElement, IfcElement __RelatedElement, IfcInteger[] __RelatingPriorities, IfcInteger[] __RelatedPriorities, IfcConnectionTypeEnum __RelatedConnectionType, IfcConnectionTypeEnum __RelatingConnectionType)
     : base(__GlobalId, __OwnerHistory, __Name, __Description, __ConnectionGeometry, __RelatingElement, __RelatedElement)
 {
     this._RelatingPriorities     = new List <IfcInteger>(__RelatingPriorities);
     this._RelatedPriorities      = new List <IfcInteger>(__RelatedPriorities);
     this._RelatedConnectionType  = __RelatedConnectionType;
     this._RelatingConnectionType = __RelatingConnectionType;
 }
示例#29
0
        /// <summary>
        /// Validate component sheet for merge types depending on the role of the model this worksheet was built from
        /// </summary>
        /// <param name="model">model the cobie file was generated from</param>
        /// <param name="fileRoles">the file roles</param>
        public List <string> ValidateComponentMerge(XbimModel model, COBieMergeRoles fileRoles)
        {
            List <string> typeObjectGlobalId     = new List <string>();
            List <string> typeObjectGlobalIdKeep = new List <string>();

            //RowsRemoved.Clear();
            if (fileRoles != COBieMergeRoles.Unknown) //if role is a single value of unknown then do no merging
            {
                COBieColumn colExtObj = Columns.Where(c => c.Value.ColumnName == "ExtObject").Select(c => c.Value).FirstOrDefault();
                COBieColumn colExtId  = Columns.Where(c => c.Value.ColumnName == "ExtIdentifier").Select(c => c.Value).FirstOrDefault();

                List <IfcElement> elements = model.InstancesLocal.OfType <IfcElement>().ToList(); //get all IfcElements,

                List <T> RemainRows = new List <T>();
                if (colExtObj != null)
                {
                    FilterValuesOnMerge mergeHelper = new FilterValuesOnMerge();

                    for (int i = 0; i < Rows.Count; i++)
                    {
                        COBieRow  row       = Rows[i];//.ElementAt(i);
                        COBieCell cell      = row[colExtObj.ColumnOrder];
                        string    extObject = cell.CellValue;
                        if (mergeHelper.Merge(extObject)) //object can be tested on
                        {
                            COBieCell cellExtId = row[colExtId.ColumnOrder];
                            string    extId     = cellExtId.CellValue;

                            IfcElement IfcElement = elements.Where(ie => ie.GlobalId.ToString() == extId).FirstOrDefault();
                            if (IfcElement != null)
                            {
                                //we need to remove the ObjectType from the type sheet
                                IfcRelDefinesByType elementDefinesByType = IfcElement.IsDefinedBy.OfType <IfcRelDefinesByType>().FirstOrDefault(); //should be only one
                                IfcTypeObject       elementType          = null;
                                if (elementDefinesByType != null)
                                {
                                    elementType = elementDefinesByType.RelatingType;
                                }

                                if (mergeHelper.Merge(IfcElement, fileRoles))
                                {
                                    RemainRows.Add((T)row);
                                    if ((elementType != null) && (!typeObjectGlobalIdKeep.Contains(elementType.GlobalId)))
                                    {
                                        typeObjectGlobalIdKeep.Add(elementType.GlobalId);
                                    }
                                }
                                else
                                {
                                    RowsRemoved.Add((T)row);
                                    if ((elementType != null) && (!typeObjectGlobalId.Contains(elementType.GlobalId)))
                                    {
                                        typeObjectGlobalId.Add(elementType.GlobalId);
                                    }
                                }
                            }
                            else
                            {
                                RemainRows.Add((T)row); //cannot evaluate IfcType so keep
                            }
                        }
                    }
                    Rows = RemainRows;
                }
            }

            typeObjectGlobalId.RemoveAll(Id => typeObjectGlobalIdKeep.Contains(Id)); //ensure we remove any type we have kept from the type object GlobalId list (ones to remove)
            return(typeObjectGlobalId);
        }
示例#30
0
 public IfcRelCoversBldgElements(IfcGloballyUniqueId __GlobalId, IfcOwnerHistory __OwnerHistory, IfcLabel?__Name, IfcText?__Description, IfcElement __RelatingBuildingElement, IfcCovering[] __RelatedCoverings)
     : base(__GlobalId, __OwnerHistory, __Name, __Description)
 {
     this.RelatingBuildingElement = __RelatingBuildingElement;
     this.RelatedCoverings        = new HashSet <IfcCovering>(__RelatedCoverings);
 }
示例#31
0
        /// <summary>
        /// Performs grouping based on the XML data provided.
        /// </summary>
        /// <param name="errLog">Stream for err output</param>
        /// <returns>True if grouping was successful. False otherwise.</returns>
        public bool PerformGrouping()
        {
            errLog = new StringWriter();

            if (_xmlDoc == null)
            {
                errLog.WriteLine("No input XML data.");
                return(false);
            }

            //get all group nodes
            XmlNodeList groups = _xmlDoc.GetElementsByTagName("group");

            if (groups == null || groups.Count == 0)
            {
                errLog.WriteLine("No group rules in the XML document");
                return(false);
            }

            //clear groups from elements
            ClearGroups(_rootGroup);


            //create group for all non-grouped elements
            IfcGroup noGroup = GetGroup("No group");

            if (noGroup == null)
            {
                noGroup = _model.Instances.New <IfcGroup>(gr => { gr.Name = "No group"; gr.Description = ""; });
                _rootGroup.AddObjectToGroup(noGroup);
            }
            List <IfcElement>    allElements = _model.Instances.OfType <IfcElement>().ToList();
            List <IfcTypeObject> allTypes    = _model.Instances.OfType <IfcTypeObject>().ToList();

            foreach (XmlNode group in groups)
            {
                grpName = GetName(group);
                if (String.IsNullOrEmpty(grpName))
                {
                    errLog.WriteLine("Group without name detected. All information in this group specification will be skipped.");
                    continue;
                }

                //search for the existing group with the same name (convert to upper case for the comparison) and create new group if none exists.
                IfcGroup iGroup = GetGroup(grpName);
                if (iGroup == null)
                {
                    iGroup = _model.Instances.New <IfcGroup>(gr => gr.Name = grpName);
                    _rootGroup.AddObjectToGroup(iGroup);
                }


                //process all ifc objects specified for the group
                XmlNodeList elements = ((XmlElement)group).GetElementsByTagName("element");
                foreach (XmlNode element in group)
                {
                    eName = GetName(element);
                    if (String.IsNullOrEmpty(eName))
                    {
                        errLog.WriteLine("Element without name detected in group '" + grpName + "'. This element will NOT be included in the");
                        continue;
                    }

                    //get elemType for reflection of attributes
                    IfcType ifcType;
                    if (!IfcMetaData.TryGetIfcType(eName, out ifcType))
                    {
                        continue;
                    }
                    else
                    {
                        elemType = ifcType.Type;
                    }
                    XbimQueryBuilder qBuilder = new XbimQueryBuilder(elemType);

                    //process all element attributes
                    XmlNodeList attributeGroups = ((XmlElement)element).GetElementsByTagName("attributes");
                    //there could be different grouping rules for attribute rules inside (all, none, oneOf, any)
                    foreach (XmlNode attrGroup in attributeGroups)
                    {
                        CreateAttributeCondition(qBuilder, attrGroup);
                    }

                    //process element properties
                    XmlNodeList propertyGroups = ((XmlElement)element).GetElementsByTagName("properties");
                    //there could be different grouping rules for attribute rules inside (all, none, oneOf, any)
                    foreach (XmlNode propGroup in propertyGroups)
                    {
                        CreatePropertyCondition(qBuilder, propGroup);
                    }


                    //element type processing
                    IEnumerable <IPersistIfcEntity> types = null;
                    XmlNodeList elTypeNodeList            = (element as XmlElement).GetElementsByTagName("elementType");
                    foreach (XmlNode elTypeNode in elTypeNodeList) //there should be just one 'elTypeNode'
                    {
                        XbimQueryBuilder typeQueryBuilder = null;
                        elTypeName = elTypeNode.InnerText;
                        if (string.IsNullOrEmpty(elTypeName))
                        {
                            errLog.WriteLine("Name of the element type is not specified for element of type '" + eName + "'. Element type conditions will not be applied. ");
                            continue;
                        }

                        IfcType ifcTypeLookup;
                        if (!IfcMetaData.TryGetIfcType(eName, out ifcTypeLookup))
                        {
                            continue;
                        }
                        else
                        {
                            elemType = ifcTypeLookup.Type;
                        }
                        if (!typeof(IfcTypeObject).IsAssignableFrom(elemType))
                        {
                            errLog.WriteLine("'" + elTypeName + "' is not type object.");
                            continue;
                        }

                        typeQueryBuilder = new XbimQueryBuilder(elTypeName);

                        //type attributes
                        XmlNodeList typeAttrGroups = ((XmlElement)element).GetElementsByTagName("typeAttributes");
                        foreach (XmlNode typeAttrGrpNode in typeAttrGroups)
                        {
                            CreateAttributeCondition(typeQueryBuilder, typeAttrGrpNode);
                        }

                        //process element type properties
                        XmlNodeList typePropGroups = ((XmlElement)element).GetElementsByTagName("typeProperties");
                        //there could be different grouping rules for attribute rules inside (all, none, oneOf, any)
                        foreach (XmlNode propGroup in typePropGroups)
                        {
                            CreatePropertyCondition(typeQueryBuilder, propGroup);
                        }


                        types = _model.Instances.Where <IPersistIfcEntity>(typeQueryBuilder.BuildQuery());
                        break;
                    }

                    //get elements and element type
                    IEnumerable <IPersistIfcEntity> instances = allElements.Where(qBuilder.BuildQuery().Compile()).ToList();

                    //check elements against element type (if defined)
                    if (types != null)
                    {
                        instances = FilterElementsByType(instances, types);
                    }

                    //add result to the group
                    foreach (var inst in instances)
                    {
                        IfcElement el = inst as IfcElement;
                        if (el != null && allElements.Remove(el))
                        {
                            IfcTypeObject type = el.GetDefiningType();
                            if (allTypes.Remove(type)) //ensure that it is not added twice
                            {
                                iGroup.AddObjectToGroup(type);
                            }

                            //get all elements of this type
                            IEnumerable <IfcRelDefinesByType> rels = _model.Instances.Where <IfcRelDefinesByType>(r => r.RelatingType == type);
                            foreach (var rel in rels)
                            {
                                IEnumerable <IfcElement> elemOfType = rel.RelatedObjects.OfType <IfcElement>();
                                foreach (var item in elemOfType)
                                {
                                    allElements.Remove(item);
                                }
                            }
                            //IfcObjectDefinition objDef = inst as IfcObjectDefinition;
                            //if (objDef != null) iGroup.AddObjectToGroup(objDef);
                        }
                    }
                }
            }

            //fill the no-group group with elements which are not in any group
            foreach (IfcTypeObject element in allTypes)
            {
                noGroup.AddObjectToGroup(element);
            }
            return(true);
        }
        /// <summary>
        /// Fill sheet rows for Component sheet
        /// </summary>
        /// <returns>COBieSheet</returns>
        public override COBieSheet <COBieComponentRow> Fill()
        {
#if DEBUG
            Stopwatch timer = new Stopwatch();
            timer.Start();
#endif
            ProgressIndicator.ReportMessage("Starting Components...");
            //Create new sheet
            COBieSheet <COBieComponentRow> components = new COBieSheet <COBieComponentRow>(Constants.WORKSHEET_COMPONENT);



            IEnumerable <IfcRelAggregates> relAggregates = Model.FederatedInstances.OfType <IfcRelAggregates>();
            IEnumerable <IfcRelContainedInSpatialStructure> relSpatial = Model.FederatedInstances.OfType <IfcRelContainedInSpatialStructure>();

            IEnumerable <IfcObject> ifcElements = ((from x in relAggregates
                                                    from y in x.RelatedObjects
                                                    where !Context.Exclude.ObjectType.Component.Contains(y.GetType())
                                                    select y).Union(from x in relSpatial
                                                                    from y in x.RelatedElements
                                                                    where !Context.Exclude.ObjectType.Component.Contains(y.GetType())
                                                                    select y)).OfType <IfcObject>(); //.GroupBy(el => el.Name).Select(g => g.First())//.Distinct().ToList();

            COBieDataPropertySetValues allPropertyValues = new COBieDataPropertySetValues();         //properties helper class
            COBieDataAttributeBuilder  attributeBuilder  = new COBieDataAttributeBuilder(Context, allPropertyValues);
            attributeBuilder.InitialiseAttributes(ref _attributes);
            //set up filters on COBieDataPropertySetValues for the SetAttributes only
            attributeBuilder.ExcludeAttributePropertyNames.AddRange(Context.Exclude.Component.AttributesEqualTo);         //we do not want listed properties for the attribute sheet so filter them out
            attributeBuilder.ExcludeAttributePropertyNamesWildcard.AddRange(Context.Exclude.Component.AttributesContain); //we do not want listed properties for the attribute sheet so filter them out
            attributeBuilder.RowParameters["Sheet"] = "Component";


            ProgressIndicator.Initialise("Creating Components", ifcElements.Count());

            foreach (var obj in ifcElements)
            {
                ProgressIndicator.IncrementAndUpdate();

                COBieComponentRow component = new COBieComponentRow(components);

                IfcElement el = obj as IfcElement;
                if (el == null)
                {
                    continue;
                }
                string name = el.Name.ToString();
                if (string.IsNullOrEmpty(name))
                {
                    name = "Name Unknown " + UnknownCount.ToString();
                    UnknownCount++;
                }
                //set allPropertyValues to this element
                allPropertyValues.SetAllPropertyValues(el); //set the internal filtered IfcPropertySingleValues List in allPropertyValues
                component.Name = name;

                string createBy = allPropertyValues.GetPropertySingleValueValue("COBieCreatedBy", false);  //support for COBie Toolkit for Autodesk Revit
                component.CreatedBy = ValidateString(createBy) ? createBy : GetTelecomEmailAddress(el.OwnerHistory);
                string createdOn = allPropertyValues.GetPropertySingleValueValue("COBieCreatedOn", false); //support for COBie Toolkit for Autodesk Revit
                component.CreatedOn = ValidateString(createdOn) ?  createdOn : GetCreatedOnDateAsFmtString(el.OwnerHistory);

                component.TypeName = GetTypeName(el);
                component.Space    = COBieHelpers.GetComponentRelatedSpace(el, Model, SpaceBoundingBoxInfo, Context);
                string description = allPropertyValues.GetPropertySingleValueValue("COBieDescription", false); //support for COBie Toolkit for Autodesk Revit
                component.Description = ValidateString(description) ? description : GetComponentDescription(el);
                string extSystem = allPropertyValues.GetPropertySingleValueValue("COBieExtSystem", false);     //support for COBie Toolkit for Autodesk Revit
                component.ExtSystem     = ValidateString(extSystem) ? extSystem : GetExternalSystem(el);
                component.ExtObject     = el.GetType().Name;
                component.ExtIdentifier = el.GlobalId;

                //set from PropertySingleValues filtered via candidateProperties
                //set the internal filtered IfcPropertySingleValues List in allPropertyValues to this element set above
                component.SerialNumber      = allPropertyValues.GetPropertySingleValueValue("SerialNumber", false);
                component.InstallationDate  = GetDateFromProperty(allPropertyValues, "InstallationDate");
                component.WarrantyStartDate = GetDateFromProperty(allPropertyValues, "WarrantyStartDate");
                component.TagNumber         = allPropertyValues.GetPropertySingleValueValue("TagNumber", false);
                component.BarCode           = allPropertyValues.GetPropertySingleValueValue("BarCode", false);
                component.AssetIdentifier   = allPropertyValues.GetPropertySingleValueValue("AssetIdentifier", false);

                components.AddRow(component);

                //fill in the attribute information
                attributeBuilder.RowParameters["Name"]      = component.Name;
                attributeBuilder.RowParameters["CreatedBy"] = component.CreatedBy;
                attributeBuilder.RowParameters["CreatedOn"] = component.CreatedOn;
                attributeBuilder.RowParameters["ExtSystem"] = component.ExtSystem;
                attributeBuilder.PopulateAttributesRows(el); //fill attribute sheet rows
            }

            components.OrderBy(s => s.Name);

            ProgressIndicator.Finalise();
#if DEBUG
            timer.Stop();
            Console.WriteLine("Time to generate Component data = {0} seconds", timer.Elapsed.TotalSeconds.ToString("F3"));
#endif


            return(components);
        }
示例#33
0
        /// <summary>
        /// Get the space name holding the element
        /// </summary>
        /// <param name="el">IfcElement to get containing space for</param>
        /// <param name="Model"></param>
        /// <param name="SpaceBoundingBoxInfo"></param>
        /// <param name="ifcSpaces"></param>
        /// <param name="Context"></param>
        /// <returns>Space name</returns>
        internal static string GetSpaceHoldingElement(IfcElement el, IfcStore Model, IEnumerable <SpaceInfo> SpaceBoundingBoxInfo, IEnumerable <IfcSpace> ifcSpaces, COBieContext Context)
        {
            string spaceName   = string.Empty;
            int    ifcSpacesId = Model.Metadata.ExpressTypeId(typeof(IfcSpace));

            using (var geomStore = Model.GeometryStore)
            {
                using (var geomReader = geomStore.BeginRead())
                {
                    // see if we have space information, if not fill information list
                    // if SpaceBoundingBoxInfo is not populated then prepare it
                    if (!SpaceBoundingBoxInfo.Any())
                    {
                        EnsureSpaceList(ifcSpaces, Model);
                        SpaceBoundingBoxInfo =
                            geomReader.ShapeInstances.Where(x => x.IfcTypeId == ifcSpacesId).Select(bb =>
                                                                                                    new SpaceInfo()
                        {
                            Rectangle = bb.BoundingBox,
                            Matrix    = bb.Transformation,
                            Name      =
                                ifcSpaces.Where(sp => (sp.EntityLabel == bb.IfcProductLabel))
                                .Select(sp => sp.Name.ToString())
                                .FirstOrDefault()
                        }
                                                                                                    ).ToList();
                    }

                    //only if we have any space information
                    if (SpaceBoundingBoxInfo.Any())
                    {
                        var t1 = geomReader.ShapeInstancesOfEntity(el).FirstOrDefault();
                        if (t1 == null)
                        {
                            return(string.Empty);
                        }
                        var t2 = t1.BoundingBox;



                        var elBoundBox    = t1.BoundingBox;
                        var elWorldMatrix = t1.Transformation;
                        //Get object space top and bottom points of the bounding box
                        var elBoxPts = new List <XbimPoint3D>
                        {
                            new XbimPoint3D(elBoundBox.X, elBoundBox.Y, elBoundBox.Z),
                            new XbimPoint3D(elBoundBox.X + elBoundBox.SizeX, elBoundBox.Y + elBoundBox.SizeY,
                                            elBoundBox.Z + elBoundBox.SizeZ),
                            elBoundBox.Centroid()
                        };

                        //convert points of the bounding box to WCS
                        IEnumerable <XbimPoint3D> elBoxPtsWCS = elBoxPts.Select(pt => elWorldMatrix.Transform(pt));
                        //see if we hit any spaces
                        spaceName = GetSpaceFromPoints(elBoxPtsWCS, SpaceBoundingBoxInfo);
                        //if we failed to get space on min points then use the remaining corner points
                        if (string.IsNullOrEmpty(spaceName))
                        {
                            XbimPoint3D elMinPt = elBoxPts[0];
                            XbimPoint3D elMaxPt = elBoxPts[1];
                            //elBoxPts.Clear(); //already tested points in list so clear them

                            //Extra testing on remaining corner points on the top and bottom plains
                            elBoxPts.Add(new XbimPoint3D(elMaxPt.X, elMaxPt.Y, elMinPt.Z));
                            elBoxPts.Add(new XbimPoint3D(elMaxPt.X, elMinPt.Y, elMinPt.Z));
                            elBoxPts.Add(new XbimPoint3D(elMinPt.X, elMaxPt.Y, elMinPt.Z));
                            elBoxPts.Add(new XbimPoint3D((elMaxPt.X - elMinPt.X) / 2.0, (elMaxPt.Y - elMinPt.Y) / 2.0, elMinPt.Z)); //centre face point

                            elBoxPts.Add(new XbimPoint3D(elMinPt.X, elMinPt.Y, elMaxPt.Z));
                            elBoxPts.Add(new XbimPoint3D(elMaxPt.X, elMinPt.Y, elMaxPt.Z));
                            elBoxPts.Add(new XbimPoint3D(elMinPt.X, elMaxPt.Y, elMaxPt.Z));
                            elBoxPts.Add(new XbimPoint3D((elMaxPt.X - elMinPt.X) / 2.0, (elMaxPt.Y - elMinPt.Y) / 2.0, elMaxPt.Z)); //centre face point
                            //convert points of the bounding box to WCS
                            elBoxPtsWCS = elBoxPts.Select(pt => elWorldMatrix.Transform(pt));
                            //see if we hit any spaces
                            spaceName = GetSpaceFromPoints(elBoxPtsWCS, SpaceBoundingBoxInfo);
                        }
                        if (string.IsNullOrEmpty(spaceName))
                        {
                            //Get tolerance size from element, 1% of smallest side size
                            double tol = elBoundBox.SizeX * 0.001;
                            if ((elBoundBox.SizeY * 0.001) < tol)
                            {
                                tol = elBoundBox.SizeY * 0.001;
                            }
                            if ((elBoundBox.SizeZ * 0.001) < tol)
                            {
                                tol = elBoundBox.SizeZ * 0.001;
                            }
                            if ((tol == 0.0) && //if tol 0.0
                                ((Context.WorkBookUnits.LengthUnit.Equals("meters", StringComparison.OrdinalIgnoreCase)) ||
                                 (Context.WorkBookUnits.LengthUnit.Equals("metres", StringComparison.OrdinalIgnoreCase))
                                )
                                )
                            {
                                tol = 0.001;
                            }

                            spaceName = GetSpaceFromClosestPoints(elBoxPtsWCS, tol, SpaceBoundingBoxInfo);
                        }
                    }
                }
            }
            return(spaceName);
        }