ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / FilterDefinition Class / ID Property
Example

In This Topic
    ID Property (FilterDefinition)
    In This Topic
    Gets the filter ID.
    Syntax
    public string ID {get;}
    Public ReadOnly Property ID As String
    Remarks
    The filter id is assigned automatically when the filter definition is constructed
    Example
    Get BuildingSceneLayer Filter ID and Filter
    string filterID1 = filter1.ID;
    var filter = bsl.GetFilter(filterID1);
    //or via Linq
    //var filter = bsl.GetFilters().FirstOrDefault(f => f.ID == filterID1);
    
    Create a Filter using Building Level and Category
    //Must be called on the MCT
    
    //refer to "Query Building Scene Layer for available Types and Values"
    //...
    //var bsl = ...;
    //At 2.x
    //var dict = bsl.QueryAvailableFieldsAndValues();
    
    //var dict = bsl.GetAvailableFieldsAndValues();
    //var categories = dict.SingleOrDefault(kvp => kvp.Key == "Category").Value;
    //var floors = dict.SingleOrDefault(kvp => kvp.Key == "BldgLevel").Value;
    
    //Make a new filter definition
    var fd = new FilterDefinition()
    {
      Name = "Floor and Category Filter",
      Description = "Example filter",
    };
    //Set up the values for the filter
    var filtervals = new Dictionary<string, List<string>>();
    filtervals.Add("BldgLevel", new List<string>() { floors[0] });
    var category_vals = categories.Where(v => v == "Walls" || v == "Stairs").ToList() ?? new List<string>();
    if (category_vals.Count() > 0)
    {
      filtervals.Add("Category", category_vals);
    }
    //Create a solid block (other option is "Wireframe")
    var fdef = new FilterBlockDefinition()
    {
      FilterBlockMode = Object3DRenderingMode.None,
      Title = "Solid Filter",
      SelectedValues = filtervals//Floor and Category
    };
    //Apply the block
    fd.FilterBlockDefinitions = new List<FilterBlockDefinition>() { fdef };
    //Add the filter definition to the layer
    //At 2.x - bsl.SetFilter(fd);
    bsl.UpdateFilter(fd);
    //Set it active. The ID is auto-generated
    bsl.SetActiveFilter(fd.ID);
    
    Remove BuildingSceneLayer Filter
    //var bsl = ...;
    //Note: Use HasFilter to check if a given filter id exists in the layer
    //Must be called on the MCT
    if (bsl.HasFilter(filter1.ID))
      bsl.RemoveFilter(filter1.ID);
    //Or remove all filters
    bsl.RemoveAllFilters();
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also