ArcObjects Framework
[Part 2 of 12]
In this part, we're going to start to look at programming the internals of ArcGIS and interacting with the ArcObjects Framework. To do this, we need to look at two things: 1) how do we get code running in ArcGIS, and 2) how do we get access to the running application for we can get at the juicy data and tools inside it.
First up, Arc Addins. These are a simple way of getting code running inside Arc.
Arc Addins (powerpoint)
Further info:
The Course Code Cookbook includes useful bits and pieces of code for the course -- send us anything you find and think useful!
If you need it at home, you can download Eclipse from the Eclipse foundation.
To find the initial Eclipse tutorials, look under:
Help -> Welcome -> Overview / Tutorials
Your starting point for coding in Arc is the ESRI
Java homepage (10.4+).
Old version (10.1-10.3; much like current site).
Even older version (sometimes useful).
If you need to install the Software Developers Kit (SDK), you can also find this here.
Info on addins can be found on the 10.4 pages at:
Developing extensions ->
ArcGIS Desktop customizations using add-ins
Info on signing addins.
Once we have code running inside Arc, we need some way of accessing the application that is running. If you're used to coding your own program this seems a bit odd, but here we're interacting with another program from inside it -- we need some gateway into it so we can talk to it and ask it for data, tools, etc. Arc is Object Orientated software, built out of objects inside other objects. We therefore need to find an object that will give us access to the overarching application.
Further info:
Info on the ArcObjects Framework for Java programmers can be found on the Java API site.
(Note that there are currently two APIs listed on the ESRI site as the latest, the other is here: API. You may want to check this if the other doesn't work)Note, however, that this appears to be a re-write of the VB pages, so:
If it says "This parameter is optional", it usually isn't.
If it says "If you don't want this parameter, just pass in zero" or "Nothing", then pass in null
.
If it gives Variant
as a return type, it returns java.lang.Object
.
When writing code in Arc you may like to consider following the ESRI naming conventions, though these are not altogether helpful if you think people unfamiliar with them will be working with your code.
More about annotations here:
Tutorial (includes details of @override)
For more on the COM, see this
Microsoft site.
If you're confused about the level of explicit casting, there's also
this longer explanation.
It is worth noting that you can build addins with Python, although the access to ArcObjects is currently more limited than with Java.
Getting the application (powerpoint)