コード例 #1
0
        public static void RemoveEntities(this IEntityCollection entityCollection, Func <IEntity, bool> predicate)
        {
            var entities = entityCollection.Where(predicate).ToArray();

            foreach (var entity in entities)
            {
                entityCollection.RemoveEntity(entity.Id);
            }
        }
コード例 #2
0
        public static void RemoveEntities(this IEntityCollection entityCollection, Func <IEntity, bool> predicate)
        {
            var entities = entityCollection.Where(predicate).ToArray();

            for (var i = 0; i < entities.Length; i++)
            {
                entityCollection.RemoveEntity(entities[i].Id);
            }
        }
コード例 #3
0
        public static void RemoveEntitiesContaining(this IEntityCollection entityCollection, params Type[] components)
        {
            var entities = entityCollection
                           .Where(entity => components.Any(x => entity.HasAllComponents(x)))
                           .ToArray();

            for (var i = 0; i < entities.Length; i++)
            {
                entityCollection.RemoveEntity(entities[i].Id);
            }
        }
コード例 #4
0
        public static void RemoveEntitiesContaining(this IEntityCollection entityCollection, params Type[] components)
        {
            var entities = entityCollection
                           .Where(entity => components.Any(type => entity.HasAllComponents(type)))
                           .ToArray();

            foreach (var entity in entities)
            {
                entityCollection.RemoveEntity(entity.Id);
            }
        }
コード例 #5
0
        public static void RemoveEntitiesContaining <T>(this IEntityCollection entityCollection)
            where T : class, IComponent
        {
            var entities = entityCollection
                           .Where(entity => entity.HasComponent <T>())
                           .ToArray();

            for (var i = 0; i < entities.Length; i++)
            {
                entityCollection.RemoveEntity(entities[i].Id);
            }
        }
コード例 #6
0
        public static void RemoveEntitiesContaining <T>(this IEntityCollection entityCollection)
            where T : class, IComponent
        {
            var entities = entityCollection
                           .Where(entity => entity.HasComponent <T>())
                           .ToArray();

            foreach (var entity in entities)
            {
                entityCollection.RemoveEntity(entity.Id);
            }
        }
コード例 #7
0
        private void MatchElementsToAlignments()
        {
            // find all elements for the curves (railings and sleepers)
            var railParts = new FilteredElementCollector(_document)
                            .OfClass(typeof(FamilyInstance))
                            .ToElements()
                            .Cast <FamilyInstance>()
                            .Where(e => AdaptiveComponentInstanceUtils.IsAdaptiveComponentInstance(e))
                            .ToList();

            foreach (var element in railParts)
            {
                // get adaptive points
                var points = AdaptiveComponentInstanceUtils.GetInstancePlacementPointElementRefIds(element)
                             .Select(r => _document.GetElement(r))
                             .Cast <ReferencePoint>()
                             .ToList();

                // match addaptive points to curves
                if (points.Count > 0)
                {
                    foreach (var record in _alignments)
                    {
                        if (ArePointsOnCurve(record.Polylines, points))
                        {
                            // find IFC element
                            IfcGloballyUniqueId id = GetIfcGUID(element);
                            var ifcElement         = i.FirstOrDefault <IfcBuildingElement>(e => e.GlobalId == id);
                            if (ifcElement != null)
                            {
                                record.Elements.Add(ifcElement);
                            }
                        }
                    }
                }
            }

            // find building elements which were not matched, possibly because they were not modelled with adaptive points
            var notMatched = i.Where <IfcBuildingElement>(e => !_alignments.Any(a => a.Elements.Contains(e)))
                             .ToList();

            foreach (var element in notMatched)
            {
                var matrix   = GetMatrixRelativeToSite(element);
                var position = matrix.Transform(new XbimPoint3D(0, 0, 0));

                Intersection    intersection = null;
                AlignmentRecord record       = null;
                // find closes alignment intersection (if any)
                foreach (var alignmentRecord in _alignments)
                {
                    var i = GetIntersection2D(alignmentRecord.Segments.ToList(), position);
                    if (i == null)
                    {
                        continue;
                    }
                    if (intersection == null || Math.Abs(intersection.OffsetLateral) > Math.Abs(i.OffsetLateral))
                    {
                        intersection = i;
                        record       = alignmentRecord;
                    }
                }

                // we found one working so lets use it
                if (record != null)
                {
                    record.Elements.Add(element);
                }
            }
        }