POST
|
Hi, I know that I can access the currently selected entities when the user clicks on custom button via Map.GetSelection. But let's say that I need the user to select a polyline somewhere along the way. Probably even from a wpf window because I need to get some information like length or num vertices from some polyline. Like this: When the user clicks on "From Polyline", he can select a polyline and my code can determine the number of segments of that polyline and the result is displayed in the textbox. Is that actually possible? And if yes, is there a best practice for doing this? What I'm basically looking for is a "pick mechanic" just like AutoCAD offers. And since I'm coming from an AutoCAD background, I've been doing this a lot and I figured it should be doable in ArcGIS Pro as well 🙂 Thanks in advance and Best Regards Christian
... View more
12-04-2017
06:02 AM
|
0
|
4
|
497
|
POST
|
Hi, I'm currently dealing with a strange error message: I'm creating a new feature class (via CreateFeatureclass_management) and adding fields (via AddField_management/AddFields_management) in C# with the Geoprocessing class and that works fine. But after creating the layers and adding the fields I'd also like to create features on these layers.. so I switch to the "Edit" ribbon and click on "Create". I click the vertices of my polyline (or whatever geometry) and when I hit F2 to finish the process, an error message appears in the "Create Features" pane: "Failed to create new feature(s). This data is currently locked by another user and cannot be saved". But the weird thing is: There's no error message when calling these management-functions via arcpy. I think it's related to adding the fields to the layer since commenting out these calls in my code also results in no error message.. but I need to add fields to new and existing feature layers so leaving this out is not an option for me. I attached a sample to reproduce the behaviour. The class "Layer" servers as a lightweight wrapper for feature layers and the management-functions are called in Layer.AddToMapAsync and Layer.SetupFieldsAsync. ArcGIS Pro is version 2.0.1 and the SDK is 2.0.0.8933. Thanks in advance for any help! Best Regards Christian
... View more
12-04-2017
04:50 AM
|
0
|
3
|
2029
|
POST
|
Hi Gwen, thanks for your reply. I'm aware that there's AddField (singular) and I got that working already. I just throught it's better to call AddFields when adding a bunch of fields instead of looping over AddField. Thanks anyway! Best regards Christian
... View more
11-14-2017
05:21 AM
|
1
|
0
|
1680
|
POST
|
Hi Narelle, thank you very much. I'm especially thankful for "help to help myself" such as the info you gave me! Best regards Christian
... View more
11-14-2017
05:20 AM
|
0
|
0
|
1680
|
POST
|
Hey, I'm trying to call AddFields_management via the Geoprocessing.ExecuteToolAsync function. And while I get other python tools working flawlessly I have a hard time adding multiple fields via AddFields_management. My main issue is how to pass the field description parameter which is a nested list in python. I tried jagged arrays, nested List<> but nothing worked. So given the "official" example.. import arcpy arcpy.env.workspace = "C:/data/district.gdb" arcpy.management.AddFields('school', [['school_name', 'TEXT', 'Name', 255, 'Hello world'], ['street_number', 'LONG', 'Street Number', None, 35]]) How would that look in C#? Thanks in advance & Best regards Christian
... View more
11-13-2017
05:53 AM
|
1
|
5
|
2304
|
POST
|
Hi Craig, thanks a lot for you reply. Your solution seems to work 🙂 If you don't mind, would you look over my code to check whether it's okay? I use it to add a new elevation surface whose source is a TIN. private Task CreateNewElevationSurface(ArcGIS.Desktop.Mapping.Map map, string surfaceName) {
return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => {
var dataConnection = new ArcGIS.Core.CIM.CIMStandardDataConnection();
dataConnection.WorkspaceConnectionString = String.Format("DATABASE={0}", System.IO.Path.GetDirectoryName(ArcGIS.Desktop.Core.Project.Current.DefaultGeodatabasePath));
dataConnection.WorkspaceFactory = ArcGIS.Core.CIM.WorkspaceFactory.Tin;
dataConnection.Dataset = "Tin";
dataConnection.DatasetType = ArcGIS.Core.CIM.esriDatasetType.esriDTTin;
var newElevationSource = new ArcGIS.Core.CIM.CIMElevationSource();
newElevationSource.VerticalUnit = ArcGIS.Core.Geometry.LinearUnit.Meters;
newElevationSource.DataConnection = dataConnection;
var newElevationSurface = new ArcGIS.Core.CIM.CIMMapElevationSurface();
newElevationSurface.Name = surfaceName;
newElevationSurface.BaseSources = new ArcGIS.Core.CIM.CIMElevationSource[1] { newElevationSource };
var definition = map.GetDefinition();
int numElevationSurfaces = definition.ElevationSurfaces.Length;
var newElevationSurfaces = new ArcGIS.Core.CIM.CIMMapElevationSurface[numElevationSurfaces + 1];
Array.Copy(definition.ElevationSurfaces, 0, newElevationSurfaces, 0, numElevationSurfaces);
newElevationSurfaces[numElevationSurfaces] = newElevationSurface;
definition.ElevationSurfaces = newElevationSurfaces;
map.SetDefinition(definition);
});
} Thanks again and Best regards Christian
... View more
09-27-2017
06:41 AM
|
0
|
1
|
1219
|
POST
|
Hi, is there a way to programmatically add a elevation surface to a map in ArcGis Pro? And while we're at it.. also add a elevation source to the new elevation surface? I know how to query a elevation surface and list the available surfaces but I didn't find a way to add new elevation surfaces. Thanks in advance! 🙂 Christian
... View more
09-26-2017
06:56 AM
|
0
|
3
|
1591
|
POST
|
Hi Clayton, thank you as well for your suggestions. The InterpolateShape_3d tool did work as well but I prefer to do it via the GetZsFromSurfaceAsync-method. Maybe I need to get accustomed to using tools in my c# code first, it doesn't really feel natural to me so far. Apart from querying the tin for heights at specific coordinates there's not really much I need in a tin API to be honest. Especially since there are already tools like "Decimate Nodes" when working with a tin Best Regards, Christian
... View more
07-11-2017
06:08 AM
|
0
|
0
|
1432
|
POST
|
Hi Sean, thank you, that's what I was looking for! Best Regards, Christian
... View more
07-11-2017
06:03 AM
|
0
|
0
|
1432
|
POST
|
Hi, I need to get the height from a tin for a given point (or a sequence of points) using the ArcGis Pro SDK. I successfully created a tin layer with the 3D Analyst Tool "Create Tin" and it looks very good in ArcGis Pro. But now I wonder how it's possible to actually get a height value from this layer? I'm aware of "Intersect3DLineWithSurface_3d" but that seems like overkill and I'd prefer to do it in plain code instead of calling a python function. Also: Extracting the polygons from the tin via the "TIN Triangle" tool gave me the tin as polygons and I tried to intersect a polygon with a polyline representing a vertical ray.. but I had no success in obtaining the height. Any help would be greatly appreciated. Thanks! Best Regards, Christian
... View more
07-10-2017
02:05 AM
|
0
|
5
|
2160
|
POST
|
Okay, I figured it would be like that.. can you give me an (even very) rough estimate when I can expect the API/SDK improvements? Thanks!
... View more
06-27-2017
04:19 AM
|
0
|
0
|
1059
|
POST
|
Okay, so the creation of the polygons is what's taking so long and not the drawing per se... thanks for the explanation! Is there a way I could speed up the creation process? Or do I just have to wait until the SDK offers more performance like you mentioned in your first answer?
... View more
06-26-2017
07:22 AM
|
0
|
3
|
1059
|
POST
|
Hi Charles, I do have one follow-up question, if you don't mind. I'm wondering why ArcGis Pro itself can draw so much faster.. for example the tool "tin triangle (3d-analyst)" creates and draws a lot of polygons really fast (depending on the input tin of course).. and I'm curious how can this be so fast and my code so slow? Or is this tool using an entirely different way of drawing the polygons? Thanks in advance and Best Regards, Christian
... View more
06-23-2017
12:07 AM
|
0
|
5
|
1059
|
POST
|
Hi Charles, thanks for your reply. I'm glad you could reproduce the issue and that your're looking into it. I'll hold out with further testing until the optimizations are implemented. Best Regards, Christian
... View more
06-07-2017
11:41 PM
|
0
|
0
|
1059
|
POST
|
Hello, I'm currently testing the performance of ArcGis Pro regarding how fast it is to create and draw polylines or polygons (the reason is that I'm comparing the performance to AutoCAD in order to find out whether we could port our software product to the ArcGis Pro platform). I came up with a sample code that draws about 10.000 triangles on an existing feature layer. But I was rather underwhelmed by the performance as it took about 24 seconds on my machine (i7-3930k, 24GB RAM, nVidia GTX 650 Ti). The same task in AutoCAD only took 0.1 seconds... But since I'm new to programming with ArcGis I might have made a stupid mistake that slows down my code a lot. So I'd be happy if someone with more knowledge could look over it and give me some hints whether I'm doing something wrong. This is my code: using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; using ArcGIS.Core.Data; using ArcGIS.Core.Geometry; using ArcGIS.Desktop.Core; using ArcGIS.Desktop.Editing; using ArcGIS.Desktop.Framework; using ArcGIS.Desktop.Framework.Contracts; using ArcGIS.Desktop.Framework.Dialogs; using ArcGIS.Desktop.Framework.Threading.Tasks; using ArcGIS.Desktop.Mapping; namespace ProAppModule1 { internal class createPolylines : Button { protected override async void OnClick() { var sw = new Stopwatch(); sw.Start(); await this.DrawPolylines(); sw.Stop(); MessageBox.Show(String.Format("Time elapsed: {0:t}", sw.Elapsed)); } private Task<bool> DrawPolylines() { var activeMapView = MapView.Active; var extent = activeMapView.Extent; //Draw about 10000 triangles. Use sqrt to have the same number of triangles in width and height even though we'll end up with more than 10000 triangles in the end int numTriangles = 10000; int rows, cols; rows = cols = (int)Math.Ceiling(Math.Sqrt(numTriangles)); double triangleWidth = extent.Width / cols; double triangleHeight = extent.Height / rows; var polylineFeatureLayer = this.GetFeatureLayerByName(activeMapView.Map, "My_Polyline"); return QueuedTask.Run(() => { var featureClass = polylineFeatureLayer.GetTable() as FeatureClass; var polylineDefinition = featureClass.GetDefinition() as FeatureClassDefinition; var spatialReference = polylineDefinition.GetSpatialReference(); var createOperation = new EditOperation(); createOperation.Name = "Draw Polylines"; createOperation.SelectNewFeatures = false; var coordinates = new Coordinate[4]; double x = extent.XMin; double y = extent.YMin; for (int i = 0; i < rows; ++i) { for (int j = 0; j < cols; ++j) { coordinates[0] = new Coordinate(x, y, 0.0); coordinates[1] = new Coordinate(x + triangleWidth, y, 0.0); coordinates[2] = new Coordinate(x + triangleWidth, y + triangleHeight, 0.0); coordinates[3] = coordinates[0]; var polyline = PolylineBuilder.CreatePolyline(coordinates, spatialReference); createOperation.Create(polylineFeatureLayer, polyline); x += triangleWidth; } x = extent.XMin; y += triangleHeight; } return createOperation.ExecuteAsync(); }); } private FeatureLayer GetFeatureLayerByName(Map map, string layerName) { var featureLayers = map.GetLayersAsFlattenedList().OfType<FeatureLayer>(); foreach (var layer in featureLayers) { if (layer.Name.Equals(layerName, StringComparison.CurrentCultureIgnoreCase)) return layer; } return null; } } } Thanks in advance! Christian
... View more
06-07-2017
07:16 AM
|
0
|
9
|
1819
|
Title | Kudos | Posted |
---|---|---|
1 | 11-13-2017 05:53 AM | |
2 | 02-15-2021 02:46 AM | |
1 | 01-21-2021 11:37 PM | |
1 | 05-28-2019 11:32 PM | |
1 | 11-14-2017 05:21 AM |
Online Status |
Offline
|
Date Last Visited |
05-16-2022
02:48 AM
|