Select to view content in your preferred language

How to pass data to an ArcMap extension?

1267
6
05-20-2014 02:23 AM
FossiG_
Deactivated User
Hello experts,

I try to find a hint, how to pass some data (a session id, user name etc.) to an ArcMap Extension. I could use a file or the registry, but I assume there is a more elegant "in-memory" way?!

Perhaps I am just missing the right term. What I try to achieve is the following:

The data originates from a desktop application which shall start ArcMap and activate the editing via the IAppRot Interface.

I have an editor extension in ArcMap with an event wired to the "OnCreateFeature" editor event. When this event is fired, some of the attributes of the recent feature shall be automatically filled.

Has anybody done sth. comparable or is there any "best practise" to consider?

Any hint is appreciated. Thanks in advance.

Regards
Fossi
0 Kudos
6 Replies
DuncanHornby
MVP Notable Contributor
I am working on a project where Acccess drives ArcMap and vice versa.

My code in Access starts a session of ArcMap (sounds like you have done that) and zooms to a feature. I have an extension that listens out for edit events.

I created a COM object which compiles to a DLL and is referenced by Access which starts the edit session so this is how I pass an ID to the application. It's important to realise this is not an AddIn but a COM class.

Another (and probably easier) method is in your other application you write your information to a specified location and your edit event looks there.

As for best practise, that to me is the one that works first and is easiest to develop so hopefully easy to maintain...
0 Kudos
FossiG_
Deactivated User
Hello Bruce,

thanks for your answer!
[...]I created a COM object which compiles to a DLL and is referenced by Access which starts the edit session so this is how I pass an ID to the application. [...]


Your approach makes me curious. Could you please be a little more specific? When you speak of starting the edit session from that DLL, you set all needed attributes directly into the new feature? Do you draw the whole sketch from outside?

So much questions...;) Thanks for your time.

Regards
Fossi
0 Kudos
DuncanHornby
MVP Notable Contributor
Bruce? Who is this Bruce? I'm Duncan! 😄

I've created a COM Class and exposed a method called StartEditing.

So in Access I create an instance of this and call the method, passing in the IApplication object.

In this method code it gets a handle on the Editor and starts the Edit session for the specified workspace:

pEditor.StartEditing(pWorkspace)


I have an Extension that is listening for edit events and writes an ID which was written to a dockable window to the feature.

So all the editing is done in ArcMap I "just" intercept the edit event. I have to test if I am actually in an MXD with the required layers or just a new blank mxd that a user happened to open up.

So my Visual studio solution contains two projects, one that is the AddIn extension and another project that creates my DLL with my COM Class, it's this one I reference in Access.
0 Kudos
FossiG_
Deactivated User
Duncan! Sorry, shame on me. *blush* I'm a bit off today.

Okay, let me try to recap and I beg your indulgence.

1. Access creates instance of COM-Class [lets call it COM]

2. Access calls COM.StartEditing with Argument IApplication -- that is a pointer to the ArcMap.Application also started by access, right?

3. COM.StartEditing gets handle on Editor through the IApplication pointer and starts edit session.

4. An ArcMap AddIn Extension listens for edit sessions.

So far - I am fine. I got an Assembly which implements the IAppRot, thats quite comparable to your COM-Class. And I got an  editor extension with OnCreateFeature-Event, too.

5. Edit event "writes an ID which was written to a dockable window to the feature". Umm, stop! Here comes the concept, that is new to me. You use a dockable window as a temporary storage?

Haven't used them before, just scanned the "Simple logging dockable window with a custom context menu" sample (http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Sample_Simple_logging_d...). I assume they they can store structured data, too?! And you hide it, or do you leave your window visible?

Looking forward to here more, thank you in advance!
Fossi
0 Kudos
DuncanHornby
MVP Notable Contributor
My dockable window has drop downs/buttons to control what the user needs to do.  I can get a handle on it and write the ID infomation to it. The editor event captures the onCreate of feature and then goes searching for the dockable window. You can expose some public properties of your extension?
0 Kudos
FossiG_
Deactivated User
Ah, okay. So your AddIn creates this dockable window und the COM-Class determines its handle and writes to it. And the onCreate in the AddIn does the same gets the handle of the window and reads the data. I think I've to dig deeper into these window extensions.

[...]You can expose some public properties of your extension?

Umm, I don't know. Haven't done something like this so far. Public properties of an ArcMap extension? Or are we talking about the other side, the assembly or in your case the COM-Class?

TIA
Fossi
0 Kudos