ArcObjects Books for 10.0 (where?????)

2909
13
10-03-2012 08:24 PM
AbelPerez
Occasional Contributor III
I am looking to create from scratch an ArcMap extension using .NET. Looking for books that detail the process. So far I have found nothing that will help me become adjusted to the .NET way of creating an extension. I have some help from tech support and some list users but wanted something more as an official reference. Anyone know of any good books I can take a look at?

As a side note I think I can sludge my way through and create a sample extension. But what I want to do is understand each step of the process. For example there are several extension types I can create and I can add several types of buttons to my toolbar. I have yet to find a good reference that explains each option and where and why to use each type.

any help is appreciated.

AGP
0 Kudos
13 Replies
DuncanHornby
MVP Notable Contributor
Abel,

Whilst it's no book it's worth looking on the developer blog that esri runs.  I found this page:

http://blogs.esri.com/esri/arcgis/2010/05/05/add-ins-for-arcgis-desktop-10/

There used to be a really good book explaining ArcObjects using VBA, but that's been made pretty much redundant now as ESRI are removing all support for VBA.

But ultimately you need to look at the help files and their samples and bash your head against a brick wall until it all works 😉

Duncan
0 Kudos
AbelPerez
Occasional Contributor III
I've looked at that article, I've looked in the Help, I've looked at the samples, I've posted on the mailing list. Yet some of it is still not explained. In creating an extension there are many more choices than a straight add-in. This is where I am lacking information. I know about the book but as you stated it's for VBA and that's gone. ArcGIS10 has been out for what 2 years and still no programming books from ESRI Press? Hard to believe.
0 Kudos
KenBuja
MVP Esteemed Contributor
What are some of the extras that you'd like to include in your extension?
0 Kudos
AbelPerez
Occasional Contributor III
Not extras but the options presented for adding say a button are confusing and there is no reference that I could find to describe each option. Same with the extension itself. there are different ways to create an extension with little info on when you might consider one over the other. I know the folks here could explain it. My need is to have an official reference that I can use today, in a couple weeks, or in a couple months once I've forgotten where all the forum post are at.

I can hack my way through it, no problem. I just want a reference that i can use just like any other programming environment.
0 Kudos
AlexanderGray
Occasional Contributor III
I think the last time there was a book on ArcObjects was 8.something.  I don't see another book on AO coming out any time.  I used to hate those books, spending countless hours doing keyword searches on the pdf.  The help has a lot in it but I had to get used to how it was organized.  Mostly I learned by looking at examples and trying things myself.  The following has a bunch of info on extensions:
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Creating_an_application...
0 Kudos
AbelPerez
Occasional Contributor III
Yeah I think it was ArcObjects at 9 with VBA. Good source but obviously I need to move on from VBA. So reading all the articles I think I know how to start, its just some pieces are just a mystery. Here is what I've gathered from my time with tech support (which I asked and she said there was really no article on how to do this but this is the way it's done):

1. Open a new project in Visual Studio (VB2010 in my case)
2. Select the .NET Framework 3.5 for our filter, select the template ArcGIS>Extending ArcObjects, then select Class Library (ArcMap)
3. In the ArcGIS Project Wizard add all references. We can remove the ones we don't use later.
4. Delete the class that's generated. we will not need it.
5. Right-click on Project and Add>New Item. Under ArcGIS>Extending ArcObjects there are 11 choices. Here lets say I can choose between Application Extension (Desktop) or Just-In-Time Extension (Desktop). What are the pros and cons of using each one? How would I go about determining how I should create my extension? The one I have written in VB6 there was only one way to create it. I'm not sure how I can determine which type will suit my needs. So I just pick JIT for the example. Now I get another option list with 8 choices. Blank JIT extension (1 for each ArcGIS application) or Configurable JIT extension (1 for each ArcGIS application). I know I choose ArcMap but what type of JIT do I choose and what determines why I would choose that type? I choose Configurable JIT extension (ArcMap)
6. Go back and do the same and Add>New Item and choose Base Toolbar so we have a toolbar as our base. A list of 5 options are given. Obvious choice here is Desktop ArcMap. What happens if I choose another option?
7. Do this again with Add>New Item and add controls such as Base Commands which are buttons. Once I select Base Command I get a list with 10 options. I choose Desktop ArcMap Command. This one seems the obvious choice but what does it really do and what do the other options do?
8. Write the code. Typically I will do this on a buttons OnClick event. The code will actually reside in separate modules.
9. Compile and test in ArcMap. In My Project in the Debug section we can add the location of ArcMap to the Start external program option and it should start up ArcMap after the compile for testing and debugging.
10. Finally after testing and compiling a release. To distribute we need to use ESRIRegAsm on the end users computer to register the DLL and categories (???) Not sure about this one. What is the standard location to install the assembly?

So to actually make the extension I can do it. I think I have the pieces. But there are a lot of options which just don't make sense to me or I am not sure what to look at to determine which is the best option for me. By process of elimination I can cut the choices down (I don't need any ArcGlobe or ArcScene stuff) but the ones that could be applicable I am just not sure what to select.

Appreciate all your help guys and gals.

Abel
0 Kudos
AlexanderGray
Occasional Contributor III
Commands, tools and extensions can work with different applications, ArcMap, ArcCatalog, Engine etc.  You get to choose which one on creation or make it generic across applications, I think you got that part.  For just In Time extensions, the "on create" doesn't happen when ArcMap starts up, only when it is needed.  This makes ArcMap start up faster but you have to be mindful of when your extension gets initialized.  The second option is what application (so ArcMap) and configurable.  Configurable extensions get placed in the ArcMap/tools/extension menu and you can turn it on and off like other ESRI extensions like Spatial analyst.  Blank extension don't have that option and are assumed always on.  So for configurable extension, IExtensionConfig gets implemented and stubbed out.  That is where the code that happens when you turn the extension on and off is.  IPersistVariant is needed to save data with the extension.
BaseToolbar has very few options, basically just the applications it is registered with, Same for basecommand except there are more types of commands based on the types of application they are supposed to interact with.
Regardless of which type you choose, you can changed it in the com registration functions but choosing the right one makes all that stuff happen.

So... Step 1 is identify the type or types of applications you need to do.  Making a command to work in ArcMap and Engine and Globe is all well and good but extra care needs to be taken to interact only with interfaces common to all of them.  If you don't need to, don't do it.

As far as using JIT extensions, unless performance is a major consideration or if you extension takes a really long time to start (maybe retrieving data from a database or network) and it is not used often, I say don't bother.  Generally if you build your own extension, its' because the users want to use it all the time, so the performance hit to start the extension will happen anyway, differing it won't gain much.  For ESRI extensions it made a lot of sense because users weren't always using 3D analyst, for example, every session.  Also if start-up times are a big deal, you might want to put some time metrics in to figure out if the JIT really makes a difference.
0 Kudos
AbelPerez
Occasional Contributor III
Thanks guys, I went ahead and started the process and it was actually not as bad as I thought. I think I was overwhelmed with the amount of info available. I'm well on my way to do a complete conversion. Couple questions:

1. For the class for the main entry there is a property for ProductName and one for Name, The ProductName it says is a friendly name shown in the extensions dialog. For Name it says a string to uniquely identify extension. I think I get ProductName but for Name do I need to make it like a GUID or something else thats easily recognizable like MyCompany.MyDepartment.MyExtension? Im not certain all the places these two properties will get used. The only thing that got me thinking about this was that I have the old VB6 extension loaded and I'm also testing the new .NET extension and wondering if there is a case where the two may clash because of similar properties.

2. Same thing for the command buttons. They have a category, and a name. The category says its localizable and used in the Customize Toolbar>Commands section of ArcMap. The name says its a unique id, non-localizable. So what should i lean towards here? Like above a GUID or one based on my company? These seem to also have a possibility to clash with the older extension.

3. Going to the Extensions dialog and unclicking my extension does not disable the extension. On my older VB6 extension if you unclicked it in the Extensions dialog the entire extension toolbar was disabled. Comparing the two projects I cant see what handles this event.

AGP

AGP
0 Kudos
AlexanderGray
Occasional Contributor III
1&2 Your components already have a GUID in the COM section.  You are meant to give a unique but readable (by the developer) name.  I usually put ProjectName_ClassName.  Keep them unique though so avoid reusing the names from your VB6 projects.  The category, caption, tool tip, etc. usually goes in the project resource file.

3.  In your commands, you can override the Enabled property.  Get a reference to your extension in the command, check the state of the extension and return false if the extension is not enabled.  Make sure you keep the reference to the extension to avoid constantly looking it up.
0 Kudos