POST
|
I have a button that looks through the active map for a layer group named "LinearRoute" and then gets a feature layer from the route within that group, then it looks for a second layer group called "Crossings" and attempts to intersect the route with each of these layers based on if its a polyline or polygon feature. This is working for the first feature run but the second time through the foreach loop after running intersect it isn't getting the updated feature list from MapView.Active.Map Should I be running this in a different way to ensure I get the results layer from each pass through the Geoprocessing.ExecuteToolAsync loop so my Count doesn't end up null? protected override async void OnClick()
{
var project = Project.Current;
var projGDBPath = Project.Current.DefaultGeodatabasePath;
Map map = MapView.Active.Map;
//get group of route feature then Route featuer layer
map.GetLayersAsFlattenedList().OfType<GroupLayer>().ToList();
map.GetLayersAsFlattenedList().OfType<GroupLayer>().Where(l => l.Parent.ToString() == "LinearRoute");
var lyrRoute = map.GetLayersAsFlattenedList().OfType<FeatureLayer>().Where(l => l.Parent.ToString() == "LinearRoute" && l.IsVisible == true).FirstOrDefault();
//null check for a feature in the route feature in the linear route group
if (lyrRoute is null)
{
//SendMsg("Intersect", "No Route Layer found in Routes Layer Group");
}
else
{
//check for crossings group layer
var lyrCrossings = map.GetLayersAsFlattenedList().OfType<FeatureLayer>().Where(l => l.Parent.ToString() == "Crossings" && l.IsVisible == true).ToList();
if (lyrCrossings is null)
{
//SendMsg("Intersect", "No Layers found in Crossings Layer Group");
}
else
{
//for each feature in crossings group run intersect based on if its a polyline or polygon crossing.
foreach (var lyr in lyrCrossings)
{
if (lyr.ShapeType == ArcGIS.Core.CIM.esriGeometryType.esriGeometryPolyline)
{
Map mapNew = MapView.Active.Map;
string outputPath = Path.Combine(projGDBPath, lyr.Name + "_Crossing_" + lyrRoute.Name);
string resultLyrName = lyr.Name + "_Crossing_" + lyrRoute.Name;
List<string> inputList = new List<string>();
inputList.Add(lyrRoute.Name);
inputList.Add(lyr.Name);
var args = Geoprocessing.MakeValueArray(inputList, outputPath, "", "", "POINT");
string toolPath = "analysis.Intersect";
IGPResult result = await Geoprocessing.ExecuteToolAsync(toolPath, args);
//update mapView after geoproccesing tool is run to get newly added results layers
mapNew = MapView.Active.Map;
int nCount = 0;
//GetLayerAsFlattenedList works for the first intersect layer but teh second pass through the foreach loop comes up null
FeatureLayer fl1 = mapNew.GetLayersAsFlattenedList().OfType<FeatureLayer>().Where(fl => fl.Name.Equals(resultLyrName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
Debug.WriteLine(resultLyrName);
await QueuedTask.Run(() =>
{
FeatureClass featureClass = fl1.GetFeatureClass();
nCount = featureClass.GetCount();
});
FrameworkApplication.AddNotification(new Notification()
{
Title = "MSG",
Message = "Feature Count Is: " + nCount.ToString(),
});
}
else if (lyr.ShapeType == ArcGIS.Core.CIM.esriGeometryType.esriGeometryPolygon)
{
//same principal but Geoprocessing.MakeValueArray(inputList, outputPath, "", "", "LINE");
}
else
{
//SendMsg("Intersect", "No polyline or polygon crossing layers found");
}
}
}
}
}
... View more
02-21-2022
02:57 PM
|
0
|
0
|
341
|
POST
|
I am interested in accessing the object data tables in AutoCAD Map and converting the layers into a file geodatabase with the object data as a field. Is this possible using DI extension 10.6 or only FME Workbench Map 3D Object Data'-reader?
... View more
11-18-2019
01:04 PM
|
0
|
1
|
547
|
POST
|
is there a way using the data interoperability extension to move CAD / Civil 3D object data to a file geodatbase field. In FME Workbench the Map 3D Object Data reader allows the exposure of the attached object data to be mapped to a field in a file geodatabase but I don't see this option in the Data Interoperability extension.
... View more
11-18-2019
12:53 PM
|
0
|
2
|
564
|
POST
|
Using pro SDK is there a way to determine if a file geodatabase feature has been changed other than enabling and using editor tracking fields to compare the current modified date vs a previous saved modified date. and checking if the record count is the same as it was?
... View more
09-19-2019
02:28 PM
|
0
|
1
|
496
|
POST
|
Using Pro SDK How can you open the geoprocessing pane in Pro and and enter text to search so it will show results? is this possible via the DAML ID for the pane?
... View more
08-20-2019
11:41 AM
|
0
|
0
|
486
|
POST
|
I tried this but when I run OpenToolDialog it is not throwing an exception so it just finishes and I see this. Is there a way to throw an exception when Tool has failed to open happens?
... View more
08-18-2019
07:23 PM
|
0
|
0
|
718
|
POST
|
Is there a way to check if a toolbox tool exists before opening it using the arcgis pro sdk? When I tried OpenToolDialog() on a tool not in the toolbox it tried to open it and failed. string analysisToolName = "C:\\Program Files\\ArcGIS\\Pro\\Resources\\ArcToolBox\\Toolboxes\\Analysis Tools.tbx\\NewToolBuffer"; var param_values = Geoprocessing.MakeValueArray(); param_values = null; if (File.Exists(analysisToolName)) { Debug.WriteLine("FOUND"); Geoprocessing.OpenToolDialog(analysisToolName, param_values); } else { Debug.WriteLine("DID NOT FIND TOOL"); }
... View more
08-17-2019
01:36 PM
|
0
|
2
|
862
|
POST
|
This may be an easy question but looking through the pro sdk samples and guides I didn't see the optimal way of getting a geodatabase feature class length in feet or miles like the python below. How do you get a feature classes full length or selection records length from the @SHAPE fields while supplying the unit of measurement you want? <code> with arcpy.da.SearchCursor(lyr, ['SHAPE@']) as cursor: for row in cursor: length += row[0].getLength("PLANAR", "FEET") print("Total length: {0}".format(length)) </code> similar to the code below but needing to specify the return unit of measurment public static void GetLength(Map map, string layer) { QueuedTask.Run(() => { FeatureLayer fl1 = map.FindLayers(layer).FirstOrDefault() as FeatureLayer; QueryFilter queryFilter = new QueryFilter(); using (ArcGIS.Core.Data.RowCursor rowCursor = fl1.Search(queryFilter = null)) { double length = 0; while (rowCursor.MoveNext()) { Feature feature1 = rowCursor.Current as Feature; Geometry geo = feature1.GetShape().Clone() as Polyline; length += GeometryEngine.Instance.Length(geo); Debug.WriteLine(length); } Debug.WriteLine("total: " + length/5280); } }); }
... View more
01-17-2019
08:04 PM
|
0
|
0
|
581
|
POST
|
awaiting GetFieldList() from Charles worked great. Thanks.
... View more
01-16-2019
04:46 PM
|
0
|
0
|
2753
|
POST
|
Thanks Rich it seems to be working but im getting an error "not all code paths return a value". Im confused if it runs the task, gets the table definition, gets the field list, adds the field name to a list, intersects 2 lists to get the first matching value, then returns the matching value, what other code path would there be? public static async Task<string> GetFieldList(string layer, string projGDBPath, List<string> fieldOneOptions) { await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { using (Geodatabase fileGeodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(projGDBPath)))) using (FeatureClassDefinition featureClass = fileGeodatabase.GetDefinition<FeatureClassDefinition>(layer)) { IReadOnlyList<Field> fields = featureClass.GetFields(); List<string> fieldList = new List<string>(); foreach (var fld in fields) { fieldList.Add(fld.Name) } string matchField = fieldOneOptions.Intersect(fieldList).FirstOrDefault().ToString(); return matchField; } }); }
... View more
01-15-2019
10:38 AM
|
1
|
2
|
2753
|
POST
|
I am trying to get a list of the fields in a feature inside the project default geodatabase. what is the c# pro sdk equivalent of the python below? for lyr in m.listLayers(): if lyr.name == "layer": field_names = [] fields = arcpy.ListFields(lyr) for field in fields: field_names.append(field.name) Do i have to go through the geodatabse API with a feature definition to get that list? like below. or is there a shorter or more prefered way? using (Geodatabase fileGeodatabase = new Geodatabase(new FileGeodatabaseConnectionPath((uri)))) using (FeatureClass featureClass = fileGeodatabase.OpenDataset<FeatureClass>(matchLyr)) { FeatureClassDefinition LyrDefinition = featureClass.GetDefinition(); IReadOnlyList<Field> fields = LyrDefinition.GetFields(); List<string> fieldList = new List<string>(); foreach (var fld in fields) { fieldList.Add(fld.Name); Debug.WriteLine(fld.Name); } return fieldList; }
... View more
01-14-2019
06:40 AM
|
0
|
5
|
3430
|
Title | Kudos | Posted |
---|---|---|
1 | 01-15-2019 10:38 AM |
Online Status |
Offline
|
Date Last Visited |
02-21-2022
04:31 PM
|