POST
|
Of course I can store the inital value of aprx.filePath in a variable and reopen the project again later but my scenario is a bit different: My Script Tool basically creates a copy of the currently opened ArcGIS Pro project to a user defined location and updates some layer connection settings. Now that saveACopy modifies the value of "CURRENT", the script obviously can't be run more than one time because the second time it's run, "CURRENT" points to the copy and not to the currently opened Project anymore. Now maybe (I haven't checked) there's the possibility of having a global variable that is persistent across multiple tool executions so I can set it the very first time.
... View more
05-12-2022
01:48 AM
|
0
|
0
|
346
|
POST
|
Hi, I've encountered weird behaviour in the saveACopy method of the arcpy.mp.ArcGISProject class. It seems that it modifies the value of "CURRENT". I've assembled a short code sample: import arcpy
def PrintFilePathOfCurrentArcGISProject(msg):
# Open the "CURRENT" project and print the file path
aprx = arcpy.mp.ArcGISProject("CURRENT")
arcpy.AddMessage(f"{msg}: {aprx.filePath}")
def main():
PrintFilePathOfCurrentArcGISProject("Before opening \"CURRENT\" aprx")
aprx = arcpy.mp.ArcGISProject("CURRENT")
aprx.saveACopy(r"D:\test_copy.aprx")
PrintFilePathOfCurrentArcGISProject("After saveACopy")
if __name__ == "__main__":
main() When running the script in ArcGIS Pro 2.9.3, the output is: Before opening "CURRENT" aprx: C:\Users\Madlener\Documents\ArcGIS\Projects\MyProject\MyProject.aprx After saveACopy: D:\test_copy.aprx I wonder if this is a bug (I certainly think it is one..) If it's not a bug, this behaviour should be documented in the saveACopy method. The problem is that I cannot restore the old value of "CURRENT" by any means. If there's a way though, I'd be glad if somebody could let me know. Thanks in advance Christian
... View more
05-12-2022
12:30 AM
|
0
|
2
|
379
|
POST
|
Hi Kirk, thanks for your reply. I didn't know that flag and commenting this line out (or using "none" instead of "pdb-only") does in fact not include the pdb and xml files of the ArcGIS Pro config (the "main program", so to speak). In order to exclude the xml and pdb files of dependencies as well, I found a solution here: https://stackoverflow.com/questions/2011434/preventing-referenced-assembly-pdb-and-xml-files-copied-to-output
... View more
12-07-2021
06:39 AM
|
0
|
0
|
580
|
POST
|
Hi, today I checked out the proConfigX file of our ArcGIS Pro application and it turns out that even though I built it in release-mode, it contained PDB files of the ArcGIS Pro application and also of the dependencies. I also found XML files of dependencies with the comments generated by VS. I don't really think it makes sense to include these files in the release target so I wonder if there's an easy way to exclude them or if I have to modify the build process so that these files are wiped before the proConfigX is put together (which is only a zip file with a special structure, if I'm not mistaken). Thanks in advance Christian
... View more
12-06-2021
05:55 AM
|
0
|
2
|
633
|
POST
|
Hi, I did test your approach and it was about 15 seconds faster. Setting useRecyclcingCursor to true didn't yield any benefits, so I didn't do that (but it also wasn't necessary to copy the shape when it was true). The speed benefit obviously came from setting the subfield. Thanks a lot for your suggestions! Best regards Christian
... View more
03-17-2021
01:05 AM
|
0
|
0
|
639
|
POST
|
Hi, simple task: I want to read polygons from a CAD layer. And I want to do it as fast as I can. The CAD layer contains a TIN network and I want to process the invidividual triangles. However, reading from the layer takes quite some time... I use the following code to read all the polygons from the layer: FeatureLayer sourceLayer = //Obtain FeatureLayer...
uint numSteps = (uint)await QueuedTask.Run(() => sourceLayer.GetTable().GetCount());
var polygons = new List<Polygon>((int)numSteps); //Holds all polygons from the layer
using (var progressDialog = new ProgressDialog("Reading polygons...", "", numSteps)) {
var cps = new CancelableProgressorSource(progressDialog);
cps.Progressor.Max = numSteps;
await QueuedTask.Run(() => {
using (var rowCursor = sourceLayer.Search()) {
while (rowCursor.MoveNext()) {
if (cps.CancellationTokenSource.IsCancellationRequested) {
polygons.Clear();
return;
}
var pg = (Polygon)rowCursor.Current["SHAPE"];
if (pg.PointCount < 3 || pg.PointCount > 4) {
//Invalid polygon shape..
continue;
}
else if (pg.PointCount == 4) {
//Check if the polygon is "closed", i.e. forms a triangle
var firstPoint = pg.Points[0];
var lastPoint = pg.Points[3];
if (firstPoint.IsEqual(lastPoint) == false)
continue;
}
polygons.Add(pg);
++cps.Value;
cps.Status = String.Format("Progress {0}%", 100.0 * cps.Value / cps.Max);
}
}
}, cps.Progressor);
}
//Do something with the polygons-list As you can see, there's nothing fancy going on. The CAD layer contains 753.780 rows and executing this code takes about 1:53 minutes, which seems slow to me. After running a profiler most of the time is spent in the RowCursor object. Is there a way to speed up reading from the CAD layer using the RowCursor or maybe there is a completely different way to read all the polygons from the layer that is faster? Any help is greatly appreciated! If anybody want to take a look, I uploaded the DWG file here: https://gofile.io/d/6Npgyw Best regards Christian
... View more
03-09-2021
01:53 AM
|
0
|
2
|
768
|
POST
|
Thank you Uma, that did the trick.. I wasn't aware that what I was calling "project tab" is referred to as backstage 🙂
... View more
02-16-2021
11:45 PM
|
0
|
0
|
1100
|
POST
|
Hi, that was already a nod in the right direction.. I came up with this: <updateModule refID="esri_core_module">
<controls>
<deleteButton refID="esri_core_newProjectButton" />
<deleteButton refID="esri_core_openProjectButton" />
<deleteButton refID="esri_core_saveProjectAsButton" />
</controls>
</updateModule> And looking at the QAT, it worked: But I can still create/open projects in the "project tab": I browsed through the DAML IDs in this link: https://github.com/Esri/arcgis-pro-sdk/wiki/DAML-ID-Reference-ADCore.daml But I couldn't figure out which ones I need to add to updateModule to get rid of new/open project in the "project tab"
... View more
02-16-2021
04:57 AM
|
0
|
0
|
1117
|
POST
|
Hi, I have created a Pro Configuration for ArcGIS Pro and through that configuration either a new project is created or a specific existing project is opened upon startup. So after ArcGIS is initialized and ready, a project is open. Now I wonder if there's a way to disable the "new project"/"open project"/"save as"-functionality in ArcGIS Pro since I don't want the user to work with a different project as long as my configuration is active. I worked around by subscribing to ProjectOpened/Saved-Events and then disabling conditions so my Add-In is not active anymore and I also used ConfigurationManager.OnCanExecuteCommand to disable new/open from the QAT.. but the user can still do it from the "Project"-Tab that's always present. Did I miss something or is this functionality not yet implemented? Thanks in advance Christian
... View more
02-15-2021
02:46 AM
|
2
|
4
|
1183
|
POST
|
Okay, I figured it out.. one needs to subscribe to ProjectClosingEvent, ProjectSavingEvent, ProjectCloseCanceledEvent and ProjectClosedEvent If project closing starts and afterwards the ProjectSavingEvent fires, the user chose to save the changes. If the ProjectCloseCanceledEvent fires, he chose to cancel the changes and if no event fires between ProjectClosingEvent and ProjectCloseEvent then the user didn't save the changes. This works but come on, I wonder why there is no specialized event just for that...
... View more
01-21-2021
11:37 PM
|
1
|
0
|
684
|
POST
|
Hi, thanks for your reply but the ProjectClosingEvent fires BEFORE ArcGIS Pro displays the MessageBox I mentioned above so obviously I can't know what the user clicked eventually from that event handler.. As I said, I looked through the events but couldn't find one that suits my needs.. I'm starting to believe that ArcGIS simply doesn't provide any means to get the info I need, but maybe you or somebody else has another idea.. Best regards Christian
... View more
01-21-2021
07:34 AM
|
0
|
0
|
685
|
POST
|
Hi, when ArcGIS Pro is closed by the user and there are pending changes like camera pan or whatever, the user is presented with the question whether the changes shall be saved: I need to know whether the user clicked Yes or No because depending on what was clicked, I need to commit/rollback a transaction in an external SQL database. I looked around and found some events like ProjectSavingEvent etc. but that doesn't quite do it for me. Is there something I missed in the SDK or is the functionality I need simply not present? Any help is greatly appreciated. Best regards Christian
... View more
01-11-2021
04:55 AM
|
0
|
3
|
753
|
POST
|
Hi Dan, you're right, that pretty much sums it up, thanks a lot. I think I can live with these limitations especially since my polygons are actually triangles so I think I can fit around 20 million triangles into the shapefile. Again, I'd rather not use shapefiles but since creating so many objects is super slow for regular FeatureClasses/FeatureLayers in the ArcGIS Pro project, I've got no other apparent choice.. Best regards Christian
... View more
09-10-2020
04:46 AM
|
0
|
0
|
685
|
POST
|
Hey, as I mentioned in an older post, I have quite some performance issues with ArcGIS Pro. Especially when I have to create like 800k polygons or something and put them on a layer it takes ages. However, I found out that it is much much faster to create a Shapefile (with the DotSpatial library) that contains the polygons and then I can simply add the Shapefile to the project. Speedup is like factor 20. Now, performance wise I actually have no choice going down this road but I wonder if there are any negative impacts that I don't know of yet? Are there any downsides of shapefiles vs using regular FeatureClasses/FeatureLayers that are stored in the ArcGIS project? Note that I rarely have to modify these objects individually.. instead all of the 800k polygons are nuked and created from scratch when changes are necessary. Thanks in advance Christian
... View more
09-10-2020
02:19 AM
|
0
|
2
|
718
|
POST
|
Fast forward two and a half years I've tested my example above again on the same machine as back then and with ArcGIS Pro 2.5.0 and the SDK Version 2.3.0.15769.. The code now takes about 7 seconds to execute for 10k polylines - which is quite an improvement over the original 24s. 20k polylines take about 14 seconds... I guess the whole thing is O(n). To be honest I find it still too slow, especially since we're talking about small values of n. In a real life scenario I have to draw 500k polylines (or polygons, whatever) at a time. I'm not asking for OpenGL drawing speed here, but as the major portion of execution time is spent creating the geometries it would be awesome to have a "batch creation" mode for such a large number of geometries. Are there any plans to speed up the drawing/creation process further? Because right now I have a tough time selling our ArcGIS Pro based software product to our customers because of such performance limitations. Thanks in advance
... View more
02-27-2020
07:33 AM
|
0
|
0
|
976
|
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
|