Slide 1

Slide 1 text

2019 Texas GIS Forum October 23, 2019 Date 2019: A Odyssey Migrating Python Add-Ins from ArcMap to ArcGIS Pro John Phillips Matt Washburn

Slide 2

Slide 2 text

2019 Texas GIS Forum October 23, 2019 Roadmap 2 § BP (Before Pro) – Why Pro? – Python Add-Ins – Choosing the Right Tools § The Journey – Learning C# – Dev Summit – Practice, Collaboration and Testing § Your Turn: Getting Started § Scenarios – Simple: Launch a native GP tool using C# – Hybrid: Launch a custom python script and run in command shell – Advanced: Completely rewrite tool in C# – C# Wiz: Customize the UI using WPF (dock panes!) § Lessons Learned

Slide 3

Slide 3 text

2019 Texas GIS Forum October 23, 2019 BP (Before Pro) Time Period – Why Pro? 3 § Geospatial Roadway Inventory Database (G.R.I.D) – Custom database application – Roadway Geometry and assets § Custom and built-in Editing, ETL and Linear Referencing Tools – Set From/To Measures – Identify Route Locations

Slide 4

Slide 4 text

2019 Texas GIS Forum October 23, 2019 BP (Before Pro) Time Period – Why Pro? 4 § End of ArcMap Era in sight § ArcGIS Pro – Multi-threaded/64-bit – C# .NET architecture – Dark Mode!! § Development of tools not on Pro roadmap or locked behind extension (Roads and Highways)

Slide 5

Slide 5 text

2019 Texas GIS Forum October 23, 2019 BP (Before Pro) Time Period – Python Add-Ins 5 § Python Add-In Wizard § Mostly limited to launching GP Tools, external python scripts § Tried to write LRS tools for Pro in python, but results weren’t consistent

Slide 6

Slide 6 text

2019 Texas GIS Forum October 23, 2019 6 § Customization Patterns: – Configure UI through settings, and workflows through Tasks (Backstage Tab, limited, no code) – Automate using geoprocessing and Python. (arcpy and arcgis API) – Extend with your own custom tools and solutions using the Pro SDK. (C# Add-Ins) – https://github.com/esri/arcgis-pro- sdk/wiki/ProConcepts-Migrating-to-ArcGIS-Pro § C# Patterns – Custom Add-Ins – Managed Configurations – Tons of options (dropdowns, context menus, dockpanes, map tools, sounds, etc) BP (Before Pro) Time Period – Choosing the Right Tools

Slide 7

Slide 7 text

2019 Texas GIS Forum October 23, 2019 The Journey – Learning C# 7 § Used Esri credits to bring out teachers – 2-Day ArcGIS Pro Course – 4-Day Extending ArcGIS Pro with Addins (EAPA) Course § Beginner/Intermediate knowledge of C# recommended for EAPA § ‘Firehose’ of information/Big learning curve § Previous programming experience helps! § After the C# course we were developing perfect add-ins with no problems!***

Slide 8

Slide 8 text

2019 Texas GIS Forum October 23, 2019 BP (Before Pro) Time Period 8

Slide 9

Slide 9 text

2019 Texas GIS Forum October 23, 2019 BP (Before Pro) Time Period 9 I’m sorry John, I’m afraid I can’t do that

Slide 10

Slide 10 text

2019 Texas GIS Forum October 23, 2019 The Journey – Dev Summit 10 § Esri Developer Summit – Developers of API teach sessions – One on one questions and feedback – Dodgeball!

Slide 11

Slide 11 text

2019 Texas GIS Forum October 23, 2019 The Journey – Practice, Collaboration and Testing 11 § Weekly learning sessions working through guide together § Esri Documentation – API/SDK Page – Community Samples – Pro Snippets – GeoNet § Testing team and bug fixes § Practice!

Slide 12

Slide 12 text

2019 Texas GIS Forum October 23, 2019 Your Turn: Getting Started 12 § Visual Studio 2017 (Community Edition is free) § ArcGIS Pro (Not free) § ArcGIS Pro SDK (Software Development Kit) – Downloaded through Visual Studio – Inserts code templates – IntelliSense

Slide 13

Slide 13 text

2019 Texas GIS Forum October 23, 2019 Four Scenarios § “Simple”: Launch a native GP tool using C# § Hybrid: Launch a custom python script and run in command shell § Advanced: Completely rewrite tool in C# § C# Wiz: Customize the UI using WPF 13

Slide 14

Slide 14 text

2019 Texas GIS Forum October 23, 2019 “Simple” Scenario § Want to run GP tool with one click § Useful for quick, commonly used operations § Control over where button is placed (context menu) § Call using C# § Example: Calculate Geometry 14

Slide 15

Slide 15 text

2019 Texas GIS Forum October 23, 2019 “Simple” Scenario § Create new VS project and add button using Pro SDK § Set path to GP tool using its alias § Set arguments based on Python documentation § Construct value array and pass those args to ExecuteToolAsync() 15

Slide 16

Slide 16 text

2019 Texas GIS Forum October 23, 2019 “Simple” Scenario § Add reference to button in the DAML (markup file) § Controls where the button is located in the application § Default is on “Add In” tab along top ribbon § Customized to add to specific context menu § Can add anywhere 16

Slide 17

Slide 17 text

2019 Texas GIS Forum October 23, 2019 Hybrid Scenario § Want to launch custom Python script with button § Pass args to script and run externally in command shell § Useful when working with legacy (i.e. 2.x) Python scripts § Allows migration to Pro without rewriting entire codebase § Example: Hello World 17

Slide 18

Slide 18 text

2019 Texas GIS Forum October 23, 2019 Hybrid Scenario 18

Slide 19

Slide 19 text

2019 Texas GIS Forum October 23, 2019 Hybrid Scenario 19 § Script launches, accepting input from user § Passes input as args in script § Could be OIDs, map selection, attributes, etc. § Useful for getting up and running quickly § Familiar Python prog patterns § Use existing scripts

Slide 20

Slide 20 text

2019 Texas GIS Forum October 23, 2019 Advanced Scenario § Need to completely rewrite Python script in C# § Not only is syntax different, not always a corresponding method § C# more verbose, many, many more ways to do one thing § Example: Jump To Google/Jump To Streetview 20

Slide 21

Slide 21 text

2019 Texas GIS Forum October 23, 2019 Advanced Scenario § Same logic, syntax and methods different § Save time/sanity by reading documentation FIRST! § Ex: Camera property accesses Scale § Use original script as pseudocode 21

Slide 22

Slide 22 text

2019 Texas GIS Forum October 23, 2019 C# Wiz § Fully customize UI with MVVM(Model View-View Model) patterns – Dockpanes – Managed Configurations – CIM Editing § Example: Dockpane! 22

Slide 23

Slide 23 text

2019 Texas GIS Forum October 23, 2019 C# Wiz § Create Dockpane using SDK template § Declare in DAML § Design layout and bind to data with XAML § Add logic in C# files 23

Slide 24

Slide 24 text

2019 Texas GIS Forum October 23, 2019 Lessons Learned 24 § Versioned Releases § Log Bugs – Spreadsheet, Trello, Bug Software § Testing – Test scripts (learn from our mistakes) § Try/Catch Statements – Very important to prevent frequent crashes § Breakpoints/Debugging/Object Explorer § Communication/Collaboration! (GitHub)

Slide 25

Slide 25 text

2019 Texas GIS Forum October 23, 2019 Date Questions? John Phillips Matt Washburn