Connect Version 13 C# Programming - ScanCriteria

Hello to All, I am having issues with ScanCriteria scanning and finding elements, I have attached the code below:

Any help would be appreciated.  In vb.net coding I used the Bentley.Interop.MicroStationDGN assembly which is a different scan process. I would like to use the Bentley.DgnPlatformNET assembly in my C# programming.

Thank you, Donna Rodrick

using Bentley.DgnPlatformNET;
using Bentley.DgnPlatformNET.Elements;

namespace SheetManager
{
 public partial class CtSheetManager : Form
 {
    //other code
 

    List<BDPN.Elements.Element> scanEls = new List<BDPN.Elements.Element>();
    scanEls.Capacity = 100;
    using (ScanCriteria scanC = new ScanCriteria())
    {
        List<MSElementType> elementTypes = new List<MSElementType>
        {
            MSElementType.Text
        };
        scanC.AddElementTypes(elementTypes);
        elementTypes.Clear();

        List<DgnElementClass> classTypes = new List<DgnElementClass>
        {
	        DgnElementClass.Construction
        };
        scanC.AddClassTypes(classTypes);
        classTypes.Clear();

        scanEls = scanC.Scan(dgnModel);
    }
    
    //more code

Parents Reply
  • Hi Donna,

    Thank you so much for your help!

    It's my pleasure ... and it did not require too much effort as I reused a code snippet from my (still growing) library of "try to understand how this piece of API works" code :-)

    To use the simple iteration is recommended by Bentley, such discussion is somewhere in this forum history.

    To use ScanCriterias is fine and more convenient for people using ScanCriteria concept in the past, but it's slower (I did some tests, but I do not remember exact results). When there are a lot of conditions and filters, the iteration could be implemented using a complex code and the performance is similar to ScanCriteria, but an advantage is it's possible to optimize exactly based on an application priorities.

    I like the ElementPropertiesGetter

    ElementPropertiesGetter and ElementPropertiesSetter are primary ways how to access an element properties.

    I truly appreciate the kindness of this group.

    Thanks :-) ... I am aware of we (me including) are not always nice, but when anybody provides own code (so it's clear he tries to do something and it's not "write code for me"), I am sure he will receive some responses from the community.

    With regards,

      Jan

Children
No Data