View in MAUI WPF WinUI View on GitHub

Explore details of a building scene by using filters and sublayer visibility.

Image of a building scene layer

Use case

Buildings and their component parts (in this example, structural, electrical, or architectural) can be difficult to explain and visualize. An architectural firm might share a 3D building model visualization with clients and contractors to let them explore these components by floor and component type.

How to use the sample

Once the scene is loaded, tap the “Building Filter Settings” button to view the filtering options.

  • Select a floor from the “Floor” menu to view the internal details of each floor or “All” to view the entire model. Selecting a floor applies a filter that hides all floors above the selected floor and gives the floors below a transparent, X-ray renderer.
  • Expand the categories under the top-level disciplines to show or hide individual categories in the building model. The entire discipline may be shown or hidden as well.
  • Tap on any features in the building to view the attributes of the feature.

How it works

  1. Create a Scene with the URL to a Building Scene Layer service.
  2. Create a LocalSceneView and add the scene.
  3. Retrieve the BuildingSceneLayer from the scene’s operational layers.
  4. When a floor is selected:
    1. A new BuildingFilter is created with two BuildingFilterBlock items.
    2. One block defines the solid renderer for features on the selected floor.
    3. The second block defines the X-ray filter for features on the floors below the selected floor.
    4. Features that exist on floors above the selected floor are not rendered.
    5. If “All” is selected, the ActiveFilter property on the building scene layer is set to null so all features are rendered according to their default settings.
  5. Architectural disciplines and categories are represented by BuildingGroupSublayer and BuildingSublayer objects containing features within a building scene layer. When checked or unchecked, the visibility of the group or sublayer is set to true (visible) or false (hidden).
  6. When a building feature is tapped on:
    1. A call to IdentifyLayerAsync on the LocalSceneView is initiated based on the screen offset of the click.
    2. The SublayerResults property of the returned IdentifyLayerResult will contain the identified features. Note that the building scene layer features are NOT returned in the GeoElements property of the results.
    3. The details of the first identified feature are shown in a popup.

Relevant API

  • BuildingComponentSublayer
  • BuildingFilter
  • BuildingFilterBlock
  • BuildingSceneLayer
  • LocalSceneView
  • Scene

About the data

This sample uses the Esri Building E Local Scene web scene, which contains a Building Scene Layer representing Building E on the Esri Campus in Redlands, CA. The Revit BIM model was brought into ArcGIS using the BIM capabilities in ArcGIS Pro and published to the web as a Building Scene Layer.

Additional information

Buildings in a Building Scene Layer can be very complex models composed of sublayers containing internal and external features of the structure. Sublayers may include structural components like columns, architectural components like floors and windows, and electrical components.

Applying filters to the Building Scene Layer can highlight features of interest in the model. Filters are made up of filter blocks, which contain several properties that allow control over the filter’s function. Setting the filter mode to X-Ray, for instance, will render features with a semi-transparent white color so other interior features can be seen. In addition, toggling the visibility of sublayers can show or hide all the features of a sublayer.

Tags

3D, building scene layer, layers

Sample Code

FilterBuildingSceneLayer.xaml FilterBuildingSceneLayer.xaml FilterBuildingSceneLayer.xaml.cs
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
x:Class="ArcGIS.Samples.FilterBuildingSceneLayer.FilterBuildingSceneLayer"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:ArcGIS.Samples.FilterBuildingSceneLayer"
xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Maui;assembly=Esri.ArcGISRuntime.Maui">
<Grid Style="{DynamicResource EsriSampleContainer}">
<!-- LocalSceneView displays the 3D building scene. -->
<esriUI:LocalSceneView x:Name="MySceneView" Style="{DynamicResource EsriSampleGeoView}" />
<!-- Control panel: toggles between settings and feature attributes. -->
<Border Style="{DynamicResource EsriSampleControlPanel}">
<Grid>
<!-- Settings panel for floor filtering and category visibility controls. -->
<ScrollView x:Name="SettingsPanel">
<VerticalStackLayout Spacing="12">
<!-- Floor selection dropdown. -->
<Grid ColumnDefinitions="Auto,*">
<Label
Grid.Column="0"
FontAttributes="Bold"
FontSize="14"
Text="Floor:"
VerticalOptions="Center" />
<Picker
x:Name="FloorPicker"
Grid.Column="1"
Margin="10,0,0,0"
SelectedIndexChanged="FloorPicker_SelectedIndexChanged" />
</Grid>
<!-- Category controls for toggling sublayer visibility. -->
<Label
FontAttributes="Bold"
FontSize="14"
Text="Categories:" />
<VerticalStackLayout x:Name="CategoriesStackLayout" Spacing="4" />
<!-- Instruction text. -->
<BoxView HeightRequest="1" Color="Gray" />
<Label
FontSize="12"
Text="Tap on a building feature to view its attributes."
TextColor="Gray" />
</VerticalStackLayout>
</ScrollView>
<!-- Feature attributes panel, shown when a feature is selected. -->
<Grid
x:Name="FeaturePanel"
IsVisible="False"
RowDefinitions="Auto,*"
RowSpacing="8">
<!-- Header with close button. -->
<Grid Grid.Row="0">
<Label
FontAttributes="Bold"
FontSize="14"
HorizontalOptions="Start"
Text="Feature Attributes"
VerticalOptions="Center" />
<Button
BackgroundColor="Gray"
Clicked="CloseFeatureButton_Clicked"
FontSize="16"
HorizontalOptions="End"
Text="✖"
TextColor="{AppThemeBinding Light=Black,
Dark=White}" />
</Grid>
<!-- Scrollable list of feature attributes. -->
<CollectionView
x:Name="FeatureAttributesCollection"
Grid.Row="1"
ItemsLayout="VerticalList"
MaximumHeightRequest="400">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="local:BuildingSceneFeatureAttribute">
<VerticalStackLayout Margin="0,4" Spacing="2">
<Label FontAttributes="Bold" FontSize="12">
<Label.FormattedText>
<FormattedString>
<Span FontAttributes="Bold" Text="{Binding Key}" />
<Span Text=":" />
</FormattedString>
</Label.FormattedText>
</Label>
<Label
Margin="10,0,0,0"
FontSize="12"
Text="{Binding Value}"
TextColor="Gray" />
</VerticalStackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</Grid>
</Grid>
</Border>
</Grid>
</ContentPage>