Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all articles
Browse latest Browse all 7260

RE: [CONNECT DgnPlatformNet] Enumerate DGN Model Elements

$
0
0

Filtering by element type also seems to be quicker with ScanCriteria.. In other cases, the ModelElementsCollection is indeed faster.


public static ScanCriteria AddElementTypes(this ScanCriteria criteria, List<MSElementType> types)
        {
            using (BitMask bitMask = new BitMask(false))
            {
                foreach (MSElementType type in types)
                    bitMask.SetBit((uint)type - 1, true);

                criteria.SetElementTypeTest(bitMask);
            }

            return criteria;
        }

public static List<Element> Scan(this ScanCriteria criteria, DgnModelRef modelRef)
        {
            List<Element> result = new List<Element>();
            criteria.SetModelRef(modelRef);
            criteria.Scan((e, m) =>
            {
                result.Add(e);

                return StatusInt.Success;
            });

            return result;
        }


Usage:
List<Element> results;

            using (ScanCriteria sc = new ScanCriteria())
            {
                DgnModel activeModel = GetActiveModel();
                results = sc.AddElementTypes(types).Scan(activeModel);
            }

            return results;

Viewing all articles
Browse latest Browse all 7260


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>