ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / FilterDefinition Class / FilterBlockDefinitions Property
Example

In This Topic
    FilterBlockDefinitions Property
    In This Topic
    Gets or sets a list of FilterBlockDefinitions.
    Syntax
    Public Property FilterBlockDefinitions As List(Of FilterBlockDefinition)
    public List<FilterBlockDefinition> FilterBlockDefinitions {get; set;}
    Remarks
    Applying more than one filter block for each ArcGIS.Core.CIM.Object3DRenderingMode type will result in an invalid filter (which cannot be set on the layer).
    Example
    Create a Default Filter and Get Filter Count
    {
      // Note: call within QueuedTask.Run()
      {
        var filter1 = bsl.CreateDefaultFilter();
        var values = filter1.FilterBlockDefinitions[0].SelectedValues;
        //values will be a single value for the type
        //"CreatedPhase", value "New Construction"
    
        //There will be at least one filter after "CreateDefaultFilter()" call
        var filtersCount = bsl.GetFilters().Count;
      }
    }
    Get all the Filters that Contain WireFrame Blocks
    {
      // Note: call within QueuedTask.Run()
      {
        //Note: wire_frame_filters can be null in this example
        var wire_frame_filters = bsl.GetFilters().Where(
          f => f.FilterBlockDefinitions.Any(
            fb => fb.FilterBlockMode == Object3DRenderingMode.Wireframe));
        //substitute Object3DRenderingMode.None to get blocks with a solid mode (default)
        //and...
        //fb.FilterBlockMode == Object3DRenderingMode.Wireframe &&
        //fb.FilterBlockMode == Object3DRenderingMode.None
        //for blocks with both
      }
    }
    Create a Filter using Building Level and Category
    {
      // Note: call within QueuedTask.Run()
      {
        //refer to "Query Building Scene Layer for available Types and Values
        var dict = bsl.GetAvailableFieldsAndValues();
        var categories = dict.SingleOrDefault(kvp => kvp.Key == "Category").Value;
        //get a list of existing floors or "levels"
        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
        bsl.UpdateFilter(fd);
        //Set it active. The ID is auto-generated
        bsl.SetActiveFilter(fd.ID);
      }
    }
    Modify BuildingSceneLayer Filter Block
    {
      // Note: call within QueuedTask.Run()
      {
        var filterBlock = new FilterBlockDefinition();
        filterBlock.FilterBlockMode = Object3DRenderingMode.Wireframe;
    
        var selectedValues = new Dictionary<string, List<string>>();
        //We assume QueryAvailableFieldsAndValues() contains "Walls" and "Doors"
        //For 'Category'
        selectedValues["Category"] = new List<string>() { "Walls", "Doors" };
        filterBlock.SelectedValues = selectedValues;
    
        //Overwrite
        filter.FilterBlockDefinitions = new List<FilterBlockDefinition>() { filterBlock };
        bsl.UpdateFilter(filter);
      }
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also