public IReadOnlyList<Layer> GetLayersAsFlattenedList()
Public Function GetLayersAsFlattenedList() As IReadOnlyList(Of Layer)
Return Value
A read only list of layers
public IReadOnlyList<Layer> GetLayersAsFlattenedList()
Public Function GetLayersAsFlattenedList() As IReadOnlyList(Of Layer)
{
//feature layer from the active map
var lookupMapView = MapView.Active;
var featureLayerLookUp = lookupMapView.Map.GetLayersAsFlattenedList()
.OfType<FeatureLayer>()
.FirstOrDefault();
await QueuedTask.Run(() =>
{
//Get the selection
var selection = featureLayerLookUp.GetSelection();
//Get the first Object ID
var firstOID = selection.GetObjectIDs().FirstOrDefault();
//Determine whether the layer's renderer type supports symbol lookup.
if (featureLayerLookUp.CanLookupSymbol())
{
//Looks up the symbol for the corresponding feature identified by the object id.
var lookupSymbol = featureLayerLookUp.LookupSymbol(firstOID, lookupMapView);
var jSon = lookupSymbol.ToJson(); //Create a JSON encoding of the symbol
//Do something with symbol
}
});
}
{
var mapToClip = MapView.Active.Map;
await QueuedTask.Run(() =>
{
//A layer to use for the clip extent
var lyrOfInterest = mapToClip.GetLayersAsFlattenedList().OfType<FeatureLayer>().Where(l => l.Name == "TestPoly").FirstOrDefault();
//Get the polygon to use to clip the map
var extent = lyrOfInterest.QueryExtent();
var polygonForClipping = PolygonBuilderEx.CreatePolygon(extent);
//Clip the map using the layer's extent
mapToClip.SetClipGeometry(polygonForClipping,
SymbolFactory.Instance.ConstructLineSymbol(
SymbolFactory.Instance.ConstructStroke(
ColorFactory.Instance.BlueRGB, 2.0, SimpleLineStyle.Dash)));
});
}
{
var mapWithClip = MapView.Active.Map;
await QueuedTask.Run(() =>
{
//If clipping is set to ArcGIS.Core.CIM.ClippingMode.None or ArcGIS.Core.CIM.ClippingMode.MapSeries null is returned
//If clipping is set to ArcGIS.Core.CIM.ClippingMode.MapExtent the ArcGIS.Core.CIM.CIMMap.CustomFullExtent is returned.
//Otherwise, if clipping is set to ArcGIS.Core.CIM.ClippingMode.CustomShape the custom clip polygon is returned.
var poly = mapWithClip.GetClipGeometry();
//You can use the polygon returned
//For example: We make a polygon graphic element and add it to a Graphics Layer.
var gl = mapWithClip.GetLayersAsFlattenedList().OfType<GraphicsLayer>().FirstOrDefault();
if (gl == null)
{
return;
}
var polygonSymbol = SymbolFactory.Instance.ConstructPolygonSymbol(CIMColor.CreateRGBColor(255, 255, 0));
var cimGraphicElement = new CIMPolygonGraphic
{
Polygon = poly,
Symbol = polygonSymbol.MakeSymbolReference()
};
gl.AddElement(cimGraphicElement);
});
}
{
await QueuedTask.Run(() =>
{
if (map == null)
{
return;
}
//Get an existing Layer. This layer has a symbol you want to use in a new layer.
var lyr = map.GetLayersAsFlattenedList().OfType<FeatureLayer>()
.Where(l => l.ShapeType == esriGeometryType.esriGeometryPoint).FirstOrDefault();
//This is the renderer to use in the new Layer
var renderer = lyr.GetRenderer() as CIMSimpleRenderer;
//Set the DataConnection for the new layer
Geodatabase geodatabase = new Geodatabase(
new FileGeodatabaseConnectionPath(new Uri(@"E:\Data\Admin\AdminData.gdb")));
FeatureClass featureClass = geodatabase.OpenDataset<FeatureClass>("Cities");
var dataConnection = featureClass.GetDataConnection();
//Create the definition for the new feature layer
var featureLayerParams = new FeatureLayerCreationParams(dataConnection)
{
RendererDefinition = new SimpleRendererDefinition(renderer.Symbol),
IsVisible = true,
};
//create the new layer
LayerFactory.Instance.CreateLayer<FeatureLayer>(
featureLayerParams, map);
});
}
{
IEnumerable<FeatureLayer> featureLayers = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>()
.Where(l => l.ShapeType == esriGeometryType.esriGeometryPoint);
var layerFile = @"C:\Data\SDK\UniqueValuePointLayer.lyrx";
foreach (var featureLayerToSymbolize in featureLayers)
{
//Get the Layer Document from the lyrx file
var lyrDocFromLyrxFile = new LayerDocument(layerFile);
var cimLyrDoc = lyrDocFromLyrxFile.GetCIMLayerDocument();
//Get the renderer from the layer file
var rendererFromLayerFile = ((CIMFeatureLayer)cimLyrDoc.LayerDefinitions[0]).Renderer as CIMUniqueValueRenderer;
//Apply the renderer to the feature layer
//Note: If working with a raster layer, use the SetColorizer method.
featureLayerToSymbolize?.SetRenderer(rendererFromLayerFile);
}
}
{
List<FeatureLayer> featureLayerList = map.GetLayersAsFlattenedList().OfType<FeatureLayer>().ToList();
}
{
//Get an existing Layer. This layer has a symbol you want to use in a new layer.
var lyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>()
.Where(l => l.ShapeType == esriGeometryType.esriGeometryPoint).FirstOrDefault();
}
{
//Finds layers by name and returns a read only list of Layers
IReadOnlyList<Layer> layers = map.FindLayers("cities", true);
//Finds a layer using a URI.
//The Layer URI you pass in helps you search for a specific layer in a map
var lyrFindLayer = MapView.Active.Map.FindLayer("CIMPATH=map/u_s__states__generalized_.xml");
//This returns a collection of layers of the "name" specified. You can use any Linq expression to query the collection.
var lyrExists = MapView.Active.Map.GetLayersAsFlattenedList()
.OfType<FeatureLayer>().Any(f => f.Name == "U.S. States (Generalized)");
}
{
IEnumerable<Layer> matches = map.GetLayersAsFlattenedList().Where(l => l.Name.Contains("partialLayerName", StringComparison.CurrentCultureIgnoreCase));
List<Layer> layers = new List<Layer>();
foreach (Layer l in matches)
{
layers.Add(l);
}
System.Diagnostics.Debug.WriteLine($"Found {layers.Count} layers with name containing '{"partialLayerName"}'");
}
{
var lyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault();
var noFeaturesSelected = lyr.SelectionCount;
}
{
await QueuedTask.Run(() =>
{
//This is the existing layer for which we want to switch the underlying datasource
var lyr = map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault();
var connectionStringToReplace = lyr.GetFeatureClass().GetDatastore().GetConnectionString();
string databaseConnectionPath = @"Path to the .sde connection file to replace with";
//If the new SDE connection did not have a dataset with the same name as in the feature layer,
//pass false for the validate parameter of the FindAndReplaceWorkspacePath method to achieve this.
//If validate is true and the SDE did not have a dataset with the same name,
//FindAndReplaceWorkspacePath will return failure
lyr.FindAndReplaceWorkspacePath(connectionStringToReplace, databaseConnectionPath, true);
});
}
{
var layers = map.GetLayersAsFlattenedList().OfType<FeatureLayer>();
var layerToQuery = layers.FirstOrDefault(f => f.Name == "USNationalParks");
if (layerToQuery == null)
{
return;
}
string whereClause = "RecreationVisitsTotal > 1000000"; //More than million visitors a year
var spatialDefnLayer = layers.FirstOrDefault(f => f.Name == "AllUSStates");
if (spatialDefnLayer == null)
{
return;
}
try
{
if (mapView == null)
{
return;
}
await QueuedTask.Run(() =>
{
// Set the spatial filter geometry
//Get the geometry from the selected features in the feature layer
var spatialClauseGeom = spatialDefnLayer.GetFeatureOutline(mapView, FeatureOutlineType.Selected);
//Create the definition query
DefinitionQuery definitionQuery = new DefinitionQuery
{
WhereClause = whereClause,
Name = $"{layerToQuery.Name}"
};
//Setting the spatial filter to the Definition Query
if (definitionQuery.CanSetFilterGeometry(spatialClauseGeom))
{
definitionQuery.SetFilterGeometry(spatialClauseGeom);
}
layerToQuery.InsertDefinitionQuery(definitionQuery);
layerToQuery.SetActiveDefinitionQuery(definitionQuery.Name);
});
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"Error querying feature layer: {ex.Message}");
}
}
{
var us_parks = map.GetLayersAsFlattenedList()
.OfType<FeatureLayer>().First(l => l.Name == "USNationalParks");
var sql = "STATE_ABBR = 'CA'";
var isValid = await us_parks.IsValidDefinitionQuery(sql);
if (isValid)
{
await QueuedTask.Run(() =>
{
var def_query = new DefinitionQuery("CaliforniaParks", sql);
us_parks.InsertDefinitionQuery(def_query);
us_parks.SetDefinitionQuery("STATE_ABBR = 'CA'");
//Set it active
us_parks.SetActiveDefinitionQuery(def_query.Name);
//or....also - set it active when it is inserted
//us_parks.InsertDefinitionQuery(def_query, true);
});
}
}
{
var greatLakes = map.GetLayersAsFlattenedList()
.OfType<FeatureLayer>().First(l => l.Name == "Great Lakes");
var usa_states = map.GetLayersAsFlattenedList()
.OfType<FeatureLayer>().First(l => l.Name == "US_States");
//name must be unique
var def_query = new DefinitionQuery("GreatLakes",
"NAME in ('Huron','Michigan','Erie')");
//create a filter geometry - in this example we will use the outline geometry
//of all visible features from a us states layer...the filter geometry will be
//intersected with the layer feature geometry when added to the def query
var filter_geom = await QueuedTask.Run(() =>
usa_states.GetFeatureOutline(mapView, FeatureOutlineType.Visible));
//other options...
//var filter_geom = usa_states.GetFeatureOutline(mapView, FeatureOutlineType.All);
//var filter_geom = usa_states.GetFeatureOutline(mapView, FeatureOutlineType.Selected);
//Geometry must have a valid SR and be point, multi-point, line, or poly
await QueuedTask.Run(() =>
{
if (def_query.CanSetFilterGeometry(filter_geom))
{
def_query.SetFilterGeometry(filter_geom);
}
});
// test to ensure the definition query is valid
var isValid = await greatLakes.IsValidDefinitionQuery(def_query);
if (isValid)
{
await QueuedTask.Run(() =>
{
//Apply the def query
greatLakes.InsertDefinitionQuery(def_query);
//Set it active
greatLakes.SetActiveDefinitionQuery(def_query.Name);
//or....also - set it active when it is inserted
//greatLakes.InsertDefinitionQuery(def_query, true);
});
}
}
{
var us_parks = map.GetLayersAsFlattenedList()
.OfType<FeatureLayer>().First(l => l.Name == "USNationalParks");
var sql = "STATE_ABBR = 'CA'";
var isValid = await us_parks.IsValidDefinitionQuery(sql);
if (isValid)
{
//inserts a new definition query and makes it active
//it will be assigned a unique name
us_parks.SetDefinitionQuery(sql);
}
}
{
var us_parks = map.GetLayersAsFlattenedList()
.OfType<FeatureLayer>().First(l => l.Name == "USNationalParks");
//enumerate the layer's definition queries - if any
var def_queries = us_parks.DefinitionQueries;
foreach (var def_qry in def_queries)
{
var geom_uri = def_qry.GeometryUri ?? "null";
var sr_wkid = def_qry.SpatialReference?.Wkid.ToString() ?? "null";
var geom = def_qry.GetFilterGeometry();
var geom_type = geom?.GeometryType.ToString() ?? "null";
System.Diagnostics.Debug.WriteLine($" def_qry.Name: {def_qry.Name}");
System.Diagnostics.Debug.WriteLine($" def_qry.WhereClause: {def_qry.WhereClause}");
System.Diagnostics.Debug.WriteLine($" def_qry.GeometryUri: {geom_uri}");
System.Diagnostics.Debug.WriteLine($" def_qry.SpatialReference: {sr_wkid}");
System.Diagnostics.Debug.WriteLine($" def_qry.FilterGeometry: {geom_type}");
System.Diagnostics.Debug.WriteLine("");
}
}
{
var greatLakes = map.GetLayersAsFlattenedList()
.OfType<FeatureLayer>().First(l => l.Name == "Great Lakes");
var michigan = map.GetBookmarks().First(b => b.Name == "Michigan");
//get all features - multiple feature geometries are always returned as a
//single multi-part
var all_features_outline = greatLakes.GetFeatureOutline(mapView, FeatureOutlineType.All);
//or get just the outline of selected features
var qry = new QueryFilter()
{
SubFields = "*",
WhereClause = "NAME in ('Huron','Michigan','Erie')"
};
greatLakes.Select(qry);
var sel_features_outline = greatLakes.GetFeatureOutline(
mapView, FeatureOutlineType.Selected);
greatLakes.ClearSelection();
//or just the visible features
mapView?.ZoomTo(michigan);
var visible_features_outline = greatLakes.GetFeatureOutline(
mapView, FeatureOutlineType.Visible);
}
{
await QueuedTask.Run(() =>
{
TinLayer tinLayer = map.GetLayersAsFlattenedList().OfType<TinLayer>().FirstOrDefault();
MapPoint mapPoint = map.CalculateFullExtent().Center; //Any Map Point
Polyline polyline = PolylineBuilderEx.CreatePolyline(mapView.Extent); //Any Polyline
if (tinLayer.CanGetZs())
{
// get z value for a mapPoint
var zResult = tinLayer.GetZs(mapPoint);
if (zResult.Status == SurfaceZsResultStatus.Ok)
{
// cast to a mapPoint
var mapPointZ = zResult.Geometry as MapPoint;
var z = mapPointZ.Z;
}
// get z values for a polyline
zResult = tinLayer.GetZs(polyline);
if (zResult.Status == SurfaceZsResultStatus.Ok)
{
// cast to a mapPoint
var polylineZ = zResult.Geometry as Polyline;
}
}
});
}
{
var usaStatesLayer = map.GetLayersAsFlattenedList().OfType<FeatureLayer>()
.FirstOrDefault(fl => fl.Name == "USA States");
if (usaStatesLayer == null)
{
return;
}
await QueuedTask.Run(() =>
{
//Create a color ramp from red to blue
var colorRampForPopulation = ColorFactory.Instance.ConstructColorRamp(
ColorRampAlgorithm.LinearContinuous,
ColorFactory.Instance.RedRGB, ColorFactory.Instance.BlueRGB);
//This Arcade expression categorizes the POP2000 field in the usaStates layer
//into Low, Medium, and High values
var arcade = @"if ($feature.POP2000 < 1000000)
{return ""Low"";}" +
@"else if ($feature.POP2000 >= 100000 && $feature.POP2000 < 5000000)
{return ""Medium""; }" +
@"else if ($feature.POP2000 >= 5000000)
{return ""High"";}" +
@"else{return ""NA"";}";
//Create the Arcade expression info
CIMExpressionInfo arcadeExp = new CIMExpressionInfo();
arcadeExp.Expression = arcade;
arcadeExp.ReturnType = ExpressionReturnType.Default;
arcadeExp.Title = "State Population Categorized";
arcadeExp.Name = "USA States Population 2000";
//Each population category is assigned a color from the color ramp and symbolized on the map
// using a unique value renderer
var uvr_desc = new UniqueValueRendererDefinition()
{
//ValueFields = new List<string> { "STATION" },
ColorRamp = colorRampForPopulation,
UseDefaultSymbol = true,
ValuesLimit = 100,
ArcadeExpression = arcadeExp.Expression
};
//Create the renderer and assign it to the layer
var renderer = usaStatesLayer.CreateRenderer(uvr_desc);
usaStatesLayer.SetRenderer(renderer);
});
}
{
//get the first group layer that has at least one table
var grp_layer = MapView.Active.Map.GetLayersAsFlattenedList()
.OfType<GroupLayer>().First(g => g.StandaloneTables.Count > 0);
grp_layer.MoveStandaloneTable(grp_layer.StandaloneTables.First(), -1);
//move the last table in the map standalone tables to a group
//layer and place it at position 3. If 3 is invalid, the table
//will be placed at the bottom of the target container
//assumes the map has at least one standalone table...
var table = map.StandaloneTables.Last();
map.MoveStandaloneTable(table, grp_layer, 3);
//move a table from a group layer to the map standalone tables
//collection - assumes a table called 'Earthquakes' exists
var table2 = grp_layer.FindStandaloneTables("Earthquakes").First();
//move to the map container
map.MoveStandaloneTable(table2, 0);//will be placed at the top
}
{
//get the first group layer that has at least one table
var grp_layer = map.GetLayersAsFlattenedList()
.OfType<GroupLayer>().First(g => g.StandaloneTables.Count > 0);
await QueuedTask.Run(() =>
{
//get the tables from the map container
var tables = map.GetStandaloneTablesAsFlattenedList();
//delete the first...
if (tables.Count() > 0)
{
map.RemoveStandaloneTable(tables.First());
//or delete all of them
map.RemoveStandaloneTables(tables);
}
//delete a table from a group layer
//assumes it has at least one table...
grp_layer.RemoveStandaloneTable(grp_layer.StandaloneTables.First());
});
}
{
//Search for only layers/tables here if needed.
MapMember mapMember = map.GetLayersAsFlattenedList().FirstOrDefault();
if (mapMember == null)
{
return;
}
await QueuedTask.Run(() =>
{
//Gets whether or not the MapMember stores its own metadata or uses metadata retrieved
//from its source.
bool doesUseSourceMetadata = mapMember.GetUseSourceMetadata();
//Sets whether or not the MapMember will use its own metadata or the metadata from
//its underlying source (if it has one).
mapMember.SetUseSourceMetadata(true);
//Does the MapMember supports metadata
var supportsMetadata = mapMember.SupportsMetadata;
//Get MapMember metadata
var metadatstring = mapMember.GetMetadata();
//TODO:Make edits to metadata using the retrieved mapMetadata string.
//Set the modified metadata back to the mapmember (layer, table..)
if (mapMember.GetCanEditMetadata())
{
mapMember.SetMetadata(metadatstring);
}
});
}
{
//Create a selection set from a list of object ids
//using FromDictionary
MapMember us_zips_layer = map.GetLayersAsFlattenedList().OfType<FeatureLayer>().First(s => s.Name == "USA zips layer");
var addToSelection = new Dictionary<MapMember, List<long>>();
addToSelection.Add(us_zips_layer, new List<long> { 1506, 2696, 2246, 1647, 948 });
//Create a SelectionSet object
var selSet = ArcGIS.Desktop.Mapping.SelectionSet.FromDictionary(addToSelection);
}
{
MapMember us_zips_layer = map.GetLayersAsFlattenedList().OfType<FeatureLayer>().First(s => s.Name == "USA zips layer");
var addToSelection = new Dictionary<MapMember, List<long>>();
addToSelection.Add(us_zips_layer, new List<long> { 1506, 2696, 2246, 1647, 948 });
//Create a SelectionSet object
var selSet = ArcGIS.Desktop.Mapping.SelectionSet.FromDictionary(addToSelection);
var selSetDict = selSet.ToDictionary();
// convert to the dictionary and only include those that are of type FeatureLayer
var selSetDictFeatureLayer = selSet.ToDictionary<FeatureLayer>();
}
{
MapMember us_zips_layer = map.GetLayersAsFlattenedList().OfType<FeatureLayer>().First(s => s.Name == "USA zips layer");
var addToSelection = new Dictionary<MapMember, List<long>>();
addToSelection.Add(us_zips_layer, new List<long> { 1506, 2696, 2246, 1647, 948 });
//Create a SelectionSet object
var selSet = ArcGIS.Desktop.Mapping.SelectionSet.FromDictionary(addToSelection);
if (selSet.Contains(us_zips_layer))
{
var oids = selSet[us_zips_layer];
}
}
{
MapMember us_zips_layer = map.GetLayersAsFlattenedList().OfType<FeatureLayer>().First(s => s.Name == "USA zips layer");
var addToSelection = new Dictionary<MapMember, List<long>>();
addToSelection.Add(us_zips_layer, new List<long> { 1506, 2696, 2246, 1647, 948 });
//Create a SelectionSet object
var selSet = ArcGIS.Desktop.Mapping.SelectionSet.FromDictionary(addToSelection);
var kvp = selSet.ToDictionary().Where(kvp => kvp.Key.Name == "LayerName").FirstOrDefault();
var oidList = kvp.Value;
}
{
mapMember = MapView.Active.Map.GetLayersAsFlattenedList().OfType<MapMember>().FirstOrDefault();
//Gets or creates the CIMMapTableView for a MapMember.
var mapTableView = FrameworkApplication.Panes.GetMapTableView(mapMember);
//Configure the table view
mapTableView.DisplaySubtypeDomainDescriptions = false;
mapTableView.SelectionMode = false;
mapTableView.ShowOnlyContingentValueFields = true;
mapTableView.HighlightInvalidContingentValueFields = true;
//Open the table pane using the configured tableView. If a table pane is already open it will be activated.
//You must be on the UI thread to call this function.
var tablePane = FrameworkApplication.Panes.OpenTablePane(mapTableView);
}
{
// find the first TIN layer
tinLayer = mapView.Map.GetLayersAsFlattenedList().OfType<TinLayer>().FirstOrDefault();
// find the first Terrain layer
terrainLayer = mapView.Map.GetLayersAsFlattenedList().OfType<TerrainLayer>().FirstOrDefault();
// find the first LAS dataset layer
lasDatasetLayer = mapView.Map.GetLayersAsFlattenedList().OfType<LasDatasetLayer>().FirstOrDefault();
// find the first surface layer
surfaceLayer = mapView.Map.GetLayersAsFlattenedList().OfType<SurfaceLayer>().FirstOrDefault();
}
{
if (map.MapType != MapType.Map)
{
return;// not 2D
}
var gl_param = new GraphicsLayerCreationParams { Name = "Graphics Layer" };
await QueuedTask.Run(() =>
{
//By default will be added to the top of the TOC
graphicsLayer = LayerFactory.Instance.CreateLayer<ArcGIS.Desktop.Mapping.GraphicsLayer>(gl_param, map);
//Add to the bottom of the TOC
gl_param.MapMemberIndex = -1; //bottom
LayerFactory.Instance.CreateLayer<ArcGIS.Desktop.Mapping.GraphicsLayer>(gl_param, map);
//Add a graphics layer to a group layer...
var group_layer = map.GetLayersAsFlattenedList().OfType<GroupLayer>().First();
LayerFactory.Instance.CreateLayer<ArcGIS.Desktop.Mapping.GraphicsLayer>(gl_param, group_layer);
//TODO...use the graphics layer
//
// or use the specific CreateGroupLayer method
LayerFactory.Instance.CreateGroupLayer(map, -1, "Graphics Layer");
});
}
{
if (map.MapType != MapType.Map)
{
// not 2D - could be a scene - no graphics layers
}
//get the first graphics layer in the map's collection of graphics layers
graphicsLayer = map.GetLayersAsFlattenedList().OfType<GraphicsLayer>().FirstOrDefault();
if (graphicsLayer != null)
{
//TODO...use the graphics layer
}
//Or, Get and set the graphic layer that acts as the target for interactive drawing tools.
targetGraphicsLayer = map.TargetGraphicsLayer; // get the target graphics layer
map.TargetGraphicsLayer = graphicsLayer; // set the target graphics layer
}
{
//Point Feature layer to convert into graphics
var lyr = mapView?.Map?.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(s => s.ShapeType == esriGeometryType.esriGeometryPoint);
if (lyr == null)
{
return;
}
await QueuedTask.Run(() =>
{
//Point symbol for graphics
var pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(CIMColor.CreateRGBColor(100, 255, 40), 10, SimpleMarkerStyle.Circle);
//Collection to hold the point graphics
var listGraphicElements = new List<CIMGraphic>();
//Iterate through each point feature in the feature layer
using (RowCursor rows = lyr.Search()) //execute
{
int i = 0;
while (rows.MoveNext())
{
using var feature = rows.Current as Feature;
//Create a point graphic for the feature
var crimePt = feature.GetShape() as MapPoint;
if (crimePt != null)
{
var cimGraphicElement = new CIMPointGraphic
{
Location = crimePt, //MapPoint
Symbol = pointSymbol.MakeSymbolReference()
};
//Add the point feature to the collection
listGraphicElements.Add(cimGraphicElement);
i++;
}
}
}
//Magic happens...Add all the features to the Graphics layer
graphicsLayer.AddElements(listGraphicElements);
});
}
/// <summary> /// Renders a feature layer using Pie chart symbols to represent data ///  /// </summary> { //Check feature layer name //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics"); if (featureLayer == null) { MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing"); } await QueuedTask.Run(() => { //Fields to use for the pie chart slices var chartFields = new List<string> { "WHITE10", "BLACK10", "AMERIND10", "ASIAN10", "HISPPOP10", "HAMERIND10", "HWHITE10", "HASIAN10", "HPACIFIC10", "HBLACK10", "HOTHRACE10" }; PieChartRendererDefinition pieChartRendererDefn = new PieChartRendererDefinition() { ChartFields = chartFields, ColorRamp = colorRamp, SizeOption = PieChartSizeOptions.Field, FieldName = "BLACK10", FixedSize = 36.89, DisplayIn3D = true, ShowOutline = true, Orientation = PieChartOrientation.CounterClockwise, }; //Creates a "Renderer" var pieChartRenderer = featureLayer.CreateRenderer(pieChartRendererDefn); //Sets the renderer to the feature layer featureLayer.SetRenderer(pieChartRenderer); }); }
/// <summary> /// Renders a feature layer using Bar chart symbols to represent data ///  /// </summary> { //Check feature layer name //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics"); if (featureLayer == null) { MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing"); } var chartFields = new List<string> { "WHITE10", "BLACK10", "AMERIND10", "ASIAN10", "HISPPOP10", "HAMERIND10", "HWHITE10", "HASIAN10", "HPACIFIC10", "HBLACK10", "HOTHRACE10" }; await QueuedTask.Run(() => { BarChartRendererDefinition barChartRendererDefn = new BarChartRendererDefinition() { ChartFields = chartFields, BarWidth = 12, BarSpacing = 1, MaximumBarLength = 65, Orientation = ChartOrientation.Vertical, DisplayIn3D = true, ShowAxes = true, ColorRamp = colorRamp }; //Creates a "Renderer" var barChartChartRenderer = featureLayer.CreateRenderer(barChartRendererDefn); //Sets the renderer to the feature layer featureLayer.SetRenderer(barChartChartRenderer); }); }
/// <summary> /// Renders a feature layer using stacked bar chart symbols to represent data ///  /// </summary> { //Check feature layer name //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics"); if (featureLayer == null) { MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing"); } var chartFields = new List<string> { "WHITE10", "BLACK10", "AMERIND10", "ASIAN10", "HISPPOP10", "HAMERIND10", "HWHITE10", "HASIAN10", "HPACIFIC10", "HBLACK10", "HOTHRACE10" }; StackedChartRendererDefinition barChartpieChartRendererDefn = new StackedChartRendererDefinition() { ChartFields = chartFields, SizeOption = StackChartSizeOptions.SumSelectedFields, Orientation = ChartOrientation.Horizontal, ShowOutline = true, DisplayIn3D = true, StackWidth = 8, StackLength = 25.87, ColorRamp = colorRamp }; await QueuedTask.Run(() => { //Creates a "Renderer" var stackedBarChartChartRenderer = featureLayer.CreateRenderer(barChartpieChartRendererDefn); //Sets the renderer to the feature layer featureLayer.SetRenderer(stackedBarChartChartRenderer); }); }
/// <summary> /// Renders a feature layer using graduated colors to draw quantities. ///  /// </summary> { //Check feature layer name //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics"); if (featureLayer == null) { MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing"); } GraduatedColorsRendererDefinition gcDef = new GraduatedColorsRendererDefinition() { ClassificationField = "NumericFieldInFeatureLayer", ClassificationMethod = ClassificationMethod.NaturalBreaks, BreakCount = 5, ColorRamp = colorRamp, }; await QueuedTask.Run(() => { CIMClassBreaksRenderer renderer = (CIMClassBreaksRenderer)featureLayer.CreateRenderer(gcDef); featureLayer?.SetRenderer(renderer); }); }
/// <summary> /// Renders a feature layer using graduated colors to draw quantities. The outline width is varied based on attributes. ///  /// </summary> { //Check feature layer name //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics"); if (featureLayer == null) { MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing"); } //Gets the first numeric field of the feature layer var firstNumericFieldOfFeatureLayer = "NumericFieldInFeatureLayer"; //Gets the min and max value of the field var minMax = await GetFieldMinMaxAsync(featureLayer, firstNumericFieldOfFeatureLayer); GraduatedColorsRendererDefinition gcDef = new GraduatedColorsRendererDefinition() { ClassificationField = "NumericFieldInFeatureLayer", ClassificationMethod = ClassificationMethod.NaturalBreaks, BreakCount = 5, ColorRamp = colorRamp }; CIMClassBreaksRenderer renderer = await QueuedTask.Run(() => (CIMClassBreaksRenderer)featureLayer.CreateRenderer(gcDef)); //Create array of CIMVisualVariables to hold the outline information. var visualVariables = new CIMVisualVariable[] { new CIMSizeVisualVariable { ValueExpressionInfo = new CIMExpressionInfo { Title = "Custom", Expression = "$feature.AREA", ReturnType = ExpressionReturnType.Default }, AuthoringInfo = new CIMVisualVariableAuthoringInfo { MinSliderValue = Convert.ToDouble(minMax.Item1), MaxSliderValue = Convert.ToDouble(minMax.Item2), ShowLegend = false, Heading = firstNumericFieldOfFeatureLayer }, VariableType = SizeVisualVariableType.Graduated, Target = "outline", MinSize = 1, MaxSize = 13, MinValue = Convert.ToDouble(minMax.Item1), MaxValue = Convert.ToDouble(minMax.Item2) }, }; renderer.VisualVariables = visualVariables; await QueuedTask.Run(() => featureLayer?.SetRenderer(renderer)); }
/// <summary> /// Renders a feature layer using graduated symbols and natural breaks to draw quantities. ///  /// </summary> { //Check feature layer name //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics"); if (featureLayer == null) { MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing"); } GraduatedSymbolsRendererDefinition gsDef = new GraduatedSymbolsRendererDefinition() { ClassificationField = "NumericFieldInFeatureLayer", //getting the first numeric field ClassificationMethod = ClassificationMethod.NaturalBreaks, SymbolTemplate = SymbolFactory.Instance.ConstructPointSymbol(CIMColor.CreateRGBColor(76, 230, 0)).MakeSymbolReference(), MinimumSymbolSize = 4, MaximumSymbolSize = 50, BreakCount = 5, ColorRamp = colorRamp, //getting a color ramp }; await QueuedTask.Run(() => { CIMClassBreaksRenderer renderer = (CIMClassBreaksRenderer)featureLayer.CreateRenderer(gsDef); featureLayer?.SetRenderer(renderer); }); }
/// <summary> /// Renders a feature layer using an unclassed color gradient. ///  /// </summary> { //Check feature layer name //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "U.S. National Transportation Atlas Interstate Highways"); if (featureLayer == null) { MessageBox.Show("This renderer works with the U.S. National Transportation Atlas Interstate Highways feature layer available with the ArcGIS Pro SDK Sample data", "Data missing"); } //Gets the first numeric field of the feature layer var firstNumericFieldOfFeatureLayer = "NumericFieldInFeatureLayer"; //Gets the min and max value of the field //Refer to the GetFieldMinMax function below var labels = await GetFieldMinMaxAsync(featureLayer, firstNumericFieldOfFeatureLayer); UnclassedColorsRendererDefinition ucDef = new UnclassedColorsRendererDefinition() { Field = firstNumericFieldOfFeatureLayer, ColorRamp = colorRamp, LowerColorStop = Convert.ToDouble(labels.Item1), UpperColorStop = Convert.ToDouble(labels.Item2), UpperLabel = labels.Item2, LowerLabel = labels.Item1, }; await QueuedTask.Run(() => { CIMClassBreaksRenderer renderer = (CIMClassBreaksRenderer)featureLayer.CreateRenderer(ucDef); featureLayer?.SetRenderer(renderer); }); }
/// <summary> /// Renders a feature layer using graduated colors and manual intervals to draw quantities. ///  /// </summary> { //Check feature layer name //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics"); if (featureLayer == null) { MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing"); } //Change these class breaks to be appropriate for your data. These class breaks defined below apply to the US States feature class List<CIMClassBreak> listClassBreaks = new List<CIMClassBreak> { new CIMClassBreak { Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB).MakeSymbolReference(), UpperBound = 24228 }, new CIMClassBreak { Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.GreenRGB).MakeSymbolReference(), UpperBound = 67290 }, new CIMClassBreak { Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.BlueRGB).MakeSymbolReference(), UpperBound = 121757 }, new CIMClassBreak { Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.GreyRGB).MakeSymbolReference(), UpperBound = 264435 }, new CIMClassBreak { Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.WhiteRGB).MakeSymbolReference(), UpperBound = 576594 } }; CIMClassBreaksRenderer cimClassBreakRenderer = new CIMClassBreaksRenderer { ClassBreakType = ClassBreakType.GraduatedColor, ClassificationMethod = ClassificationMethod.Manual, Field = "NumericFieldInLayer", //Important to add the Minimum break for your data to be classified correctly. //This is vital especially if you have data with negative values. //MinimumBreak = Breaks = listClassBreaks.ToArray() }; await QueuedTask.Run(() => featureLayer?.SetRenderer(cimClassBreakRenderer)); }
/// <summary> /// Renders a polygon feature layer with Dot Density symbols to represent quantities. ///  /// </summary> { //Check feature layer name //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics"); if (featureLayer == null) { MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing"); } //Define size of the dot to use for the renderer int dotSize = 3; //Check if the TOTPOP10 field exists int idxField = -1; idxField = await QueuedTask.Run(() => { using var table = featureLayer.GetTable(); var def = table.GetDefinition(); return def.FindField("TOTPOP10"); }); // "TOTPOP10" field was not found if (idxField == -1) { return; } //array of fields to be represented in the renderer var valueFields = new List<string> { "TOTPOP10" }; await QueuedTask.Run(() => { //Create the DotDensityRendererDefinition object var dotDensityDef = new DotDensityRendererDefinition(valueFields, colorRamp, dotSize, 30000, "Dot", "people"); //Create the renderer using the DotDensityRendererDefinition CIMDotDensityRenderer dotDensityRndr = (CIMDotDensityRenderer)featureLayer.CreateRenderer(dotDensityDef); //if you want to customize the dot symbol for the renderer, create a "DotDensitySymbol" which is an //Amalgamation of 3 symbol layers: CIMVectorMarker, CIMSolidFill and CIMSolidStroke //Define CIMVectorMarker layer var cimMarker = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.RedRGB, dotSize); var dotDensityMarker = cimMarker as CIMVectorMarker; //Define the placement CIMMarkerPlacementInsidePolygon markerPlacement = new CIMMarkerPlacementInsidePolygon { Randomness = 100, GridType = PlacementGridType.RandomFixedQuantity, Clipping = PlacementClip.RemoveIfCenterOutsideBoundary }; dotDensityMarker.MarkerPlacement = markerPlacement; //Define CIMSolidFill layer CIMSolidFill solidFill = new CIMSolidFill { Color = new CIMRGBColor { R = 249, G = 232, B = 189, Alpha = 50 } }; //Define CIMSolidStroke CIMSolidStroke solidStroke = new CIMSolidStroke { Color = ColorFactory.Instance.GreyRGB, Width = .5 }; //Create the amalgamated CIMPolygonSymbol that includes the 3 layers var dotDensitySymbol = new CIMPolygonSymbol { SymbolLayers = new CIMSymbolLayer[] { dotDensityMarker, solidFill, solidStroke } }; //Apply the dotDensitySymbol to the CIMDotDenstityRenderer's DotDensitySymbol property. dotDensityRndr.DotDensitySymbol = dotDensitySymbol.MakeSymbolReference(); //Apply the renderer to the polygon Feature Layer. featureLayer.SetRenderer(dotDensityRndr); }); }
/// <summary> /// Renders a point feature layer using a continuous color gradient to represent density of points. ///  /// </summary> { //Check feature layer name //Code works with the U.S. Cities feature layer available with the ArcGIS Pro SDK Sample data var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "U.S. Cities"); if (featureLayer == null) { MessageBox.Show("This renderer works with the U.S. Cities feature layer available with the ArcGIS Pro SDK Sample data", "Data missing"); } //defining a heatmap renderer that uses values from Population field as the weights HeatMapRendererDefinition heatMapDef = new HeatMapRendererDefinition() { Radius = 20, WeightField = "NumericField", ColorRamp = colorRamp, RendereringQuality = 8, UpperLabel = "High Density", LowerLabel = "Low Density" }; await QueuedTask.Run(() => { CIMHeatMapRenderer heatMapRndr = (CIMHeatMapRenderer)featureLayer.CreateRenderer(heatMapDef); featureLayer.SetRenderer(heatMapRndr); }); }
/// <summary> /// Renders a feature layer using proportional symbols to draw quantities. ///  /// </summary> { //Check feature layer name //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics"); if (featureLayer == null) { MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing"); } //Gets the first numeric field of the feature layer var firstNumericFieldOfFeatureLayer = "NumericFieldInLayer"; //Gets the min and max value of the field var sizes = await GetFieldMinMaxAsync(featureLayer, firstNumericFieldOfFeatureLayer); ProportionalRendererDefinition prDef = new ProportionalRendererDefinition() { Field = firstNumericFieldOfFeatureLayer, MinimumSymbolSize = 4, MaximumSymbolSize = 50, LowerSizeStop = Convert.ToDouble(sizes.Item1), UpperSizeStop = Convert.ToDouble(sizes.Item2) }; await QueuedTask.Run(() => { CIMProportionalRenderer propRndr = (CIMProportionalRenderer)featureLayer.CreateRenderer(prDef); featureLayer.SetRenderer(propRndr); }); }
/// <summary> /// Renders a Polygon feature layer using a single symbol. ///  /// </summary> { //Check feature layer name //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics"); if (featureLayer == null) { MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing"); } //Creating a polygon with a red fill and blue outline. CIMStroke outline = SymbolFactory.Instance.ConstructStroke( ColorFactory.Instance.BlueRGB, 2.0, SimpleLineStyle.Solid); CIMPolygonSymbol fillWithOutline = SymbolFactory.Instance.ConstructPolygonSymbol( ColorFactory.Instance.CreateRGBColor(255, 190, 190), SimpleFillStyle.Solid, outline); await QueuedTask.Run(() => { //Get the layer's current renderer CIMSimpleRenderer renderer = featureLayer.GetRenderer() as CIMSimpleRenderer; //Update the symbol of the current simple renderer renderer.Symbol = fillWithOutline.MakeSymbolReference(); //Update the feature layer renderer featureLayer.SetRenderer(renderer); }); }
/// <summary> /// Renders a Point feature layer using a single symbol. ///  /// </summary> { //Check feature layer name //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.ShapeType == esriGeometryType.esriGeometryPoint); if (featureLayer == null) { MessageBox.Show("This renderer works with a point feature layer", "Data missing"); } //Create a circle marker var pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.RedRGB, 8, SimpleMarkerStyle.Circle); await QueuedTask.Run(() => { //Get the layer's current renderer CIMSimpleRenderer renderer = featureLayer.GetRenderer() as CIMSimpleRenderer; //Update the symbol of the current simple renderer renderer.Symbol = pointSymbol.MakeSymbolReference(); //Update the feature layer renderer featureLayer.SetRenderer(renderer); }); }
/// <summary> /// Renders a Line feature layer using a single symbol. ///  /// </summary> { //Check feature layer name //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "U.S. National Transportation Atlas Interstate Highways"); if (featureLayer == null) { MessageBox.Show("This renderer works with the U.S. National Transportation Atlas Interstate Highways feature layer available with the ArcGIS Pro SDK Sample data", "Data missing"); } //Create a circle marker var lineSymbol = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.RedRGB, 2, SimpleLineStyle.DashDotDot); await QueuedTask.Run(() => { //Get the layer's current renderer CIMSimpleRenderer renderer = featureLayer.GetRenderer() as CIMSimpleRenderer; //Update the symbol of the current simple renderer renderer.Symbol = lineSymbol.MakeSymbolReference(); //Update the feature layer renderer featureLayer.SetRenderer(renderer); }); }
/// <summary> /// Renders a Line feature layer using a style from a StyleProjectItem. ///  /// </summary> { //Check feature layer name //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "U.S. National Transportation Atlas Interstate Highways"); if (featureLayer == null) { MessageBox.Show("This renderer works with the U.S. National Transportation Atlas Interstate Highways feature layer available with the ArcGIS Pro SDK Sample data", "Data missing"); } //Get all styles in the project var styleProjectItem2D = project.GetItems<StyleProjectItem>().FirstOrDefault(s => s.Name == "ArcGIS 2D"); //Get a specific style in the project by name var arrowLineSymbol = styleProjectItem2D.SearchSymbols(StyleItemType.LineSymbol, "Arrow Line 2 (Mid)")[0]; if (arrowLineSymbol == null) { return; } await QueuedTask.Run(() => { //Get the layer's current renderer var renderer = featureLayer?.GetRenderer() as CIMSimpleRenderer; //Update the symbol of the current simple renderer renderer.Symbol = arrowLineSymbol.Symbol.MakeSymbolReference(); //Update the feature layer renderer featureLayer.SetRenderer(renderer); }); }
/// <summary> /// Renders a feature layer using unique values from one or multiple fields ///  /// </summary> { //Check feature layer name //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics"); if (featureLayer == null) { MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing"); } //construct unique value renderer definition UniqueValueRendererDefinition uvr = new UniqueValueRendererDefinition() { //Refer to the function below to get a display field of the feature layer ValueFields = new List<string> { await GetDisplayFieldAsync(featureLayer) }, //multiple fields in the array if needed. ColorRamp = colorRamp, //Specify color ramp }; //Creates a "Renderer" await QueuedTask.Run(() => { var cimRenderer = featureLayer.CreateRenderer(uvr); //Sets the renderer to the feature layer featureLayer.SetRenderer(cimRenderer); }); //Function to get the display field of a feature layer static Task<string> GetDisplayFieldAsync(FeatureLayer featureLayer) { return QueuedTask.Run(() => { // get the CIM definition from the layer var cimFeatureDefinition = featureLayer.GetDefinition() as ArcGIS.Core.CIM.CIMBasicFeatureLayer; // get the view of the source table underlying the layer var cimDisplayTable = cimFeatureDefinition.FeatureTable; // this field is used as the 'label' to represent the row return cimDisplayTable.DisplayField; }); } }
{
var bsl_discipline = MapView.Active.Map.GetLayersAsFlattenedList().OfType<BuildingDisciplineSceneLayer>().FirstOrDefault(l => l.Name == "Architectural");
var disciplineName = bsl_discipline.GetDiscipline();
}
{
var bldgLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<BuildingSceneLayer>().First();
var disciplines = new Dictionary<string, BuildingDisciplineSceneLayer>();
//A Building layer has two children - Overview and FullModel
//Overview is a FeatureSceneLayer
//Full Model is a BuildingDisciplineSceneLayer that contains the disciplines
var fullModel = bldgLayer.FindLayers("Full Model").First()
as BuildingDisciplineSceneLayer;
//collect information on the disciplines
var name = fullModel.Name;
var discipline = fullModel.GetDiscipline();
//etc
//TODO - use collected information
disciplines.Add(discipline, fullModel);
//Discipline layers are composite layers too
foreach (var childDiscipline in fullModel.Layers
.OfType<BuildingDisciplineSceneLayer>())
{
//Discipline layers can also contain FeatureSceneLayers that render the
//individual full model contents
var content_names = string.Join(", ", childDiscipline.Layers
.OfType<FeatureSceneLayer>().Select(fl => fl.Name));
// Recursively call this "function" to go deeper
}
}
{
bsl = MapView.Active.Map.GetLayersAsFlattenedList()
.OfType<BuildingSceneLayer>().FirstOrDefault();
var scenelayerName = bsl.Name;
}
{
featSceneLayer = MapView.Active.Map.GetLayersAsFlattenedList()
.OfType<FeatureSceneLayer>().FirstOrDefault();
if (!featSceneLayer.HasAssociatedFeatureService ||
!featSceneLayer.IsEditable)
{
//not supported - exit the function
}
//TODO continue editing here...
}
{
featSceneLayer = MapView.Active.Map.GetLayersAsFlattenedList()
.OfType<FeatureSceneLayer>().FirstOrDefault();
var scenelayerName = featSceneLayer?.Name;
}
{
var trackAwareLayers = MapView.Active.Map.GetLayersAsFlattenedList()
.OfType<StreamLayer>().Where(sl => sl.IsTrackAware)?.ToList();
}
{
//Get selected layer if a voxel layer is selected
voxelLayer = MapView.Active.GetSelectedLayers().OfType<VoxelLayer>().FirstOrDefault();
if (voxelLayer == null)
{
//just get the first voxel layer in the TOC
voxelLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<VoxelLayer>().FirstOrDefault();
if (voxelLayer == null)
{
return;
}
}
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)