Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I think I've just hit a major limitation with how ArcMap (10) deals with class extensions on a Feature Class but I would first like to make sure I'm not missing something or seeing a bug.

I have a class extension registered with a feature class and the extension creates a unique identifier for every new feature that is created - it listens to the IObjectClassEvents.OnCreate event. This event is fired and handled every time a feature is created within an edit session using the 'Create Features' template. Similiarly, if I select one of more features, then Ctrl+c Ctrl+v the OnCreate event is fired for each feature and a new ID is assigned, rather than a copy of the old one - Great!

However, if I use the Advanced Editing - Copy Features tool no events are fired at all, even though new features are created. Perhaps this Copy Features tool uses a python script or something and therefore isn't managed in the same way? I don't know, but I thought it was the geodatabase which threw the OnCreate event so it shouldn't matter how the feature is created.

Can anyone tell me why none of the IObjectClassEvents events are fired in this case? I am considering looking into nasty workarounds (like a command add-in which listens for edit events when enabled) but 1) I'd really rather not and 2) I might end up with exactly the same problem.

Finally, I know there are other options than a class extension for what I'm doing but in order to fulfil all of the tool's requirements I can't use an editor extension.

Any help very much appreciated.

share|improve this question

2 Answers 2

up vote 4 down vote accepted

It is by-passing Object Store() behavior. A "quick" (ok, laughing a bit) glance of the GeoDatabase Object Model reveals that you can optionally implement IObjectClassInfo2. try implementing that and returning FALSE for the CanByPassStoreMethod.

share|improve this answer
    
Thanks very much Ragi - setting the CanByPassStoreMethod to false within my extension means that the OnCreate event is fired as expected. –  tomfumb Oct 28 '11 at 19:13
    
I assume you implemented a Class Extension using instructions similar to help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/… Look at the section related to IObjectClassInfo2. this will only affect the class that has the ObjectClass Extension. Another option is to Use the approach that @SeaJunk recommended - and it will work - but it will also force all FeatureClasses in the Workspace to behave that way, and thus will slow down your inserts considerably. –  Ragi Yaser Burhum Oct 28 '11 at 19:14
    
+1 I find the statement "By default, CanBypassStoreMethod returns true" a bit confusing when describing an optional interface. Apparently it means that if you don't implement the interface, then this is the behavior - and not a prescription for how you should implement it. –  Kirk Kuykendall Oct 28 '11 at 22:42
    
@KirkKuykendall yeah, the documentation is kind of confusing :) And yes, that is what it means. So by "default" you want things fast, even if it means skipping object event notification. So if you do not implement the interface, you get fast behavior. However, if you do not feel this is OK (as it is in this case), you can just implement this interface and say "I am relying on this event to be triggered and I do not care if everything gets slower" –  Ragi Yaser Burhum Oct 28 '11 at 23:58

Copy Features uses an insert cursor to 'store' the result and hence doesnt fire OnCreateFeature.

Take a look at the following help topic and follow the advice in the 'Feature events and cursors' heading if you want to listen to that event when using CopyFeatures.

Responding to feature or row edits

share|improve this answer
    
I've run across this back in the 9.x days with the Auto-Complete Polygon task. I'm glad ESRI finally addresses this in their help documentation. –  kenbuja Oct 28 '11 at 18:30
    
Thanks for your input I will have a look. However I suspect my main problem will remain - as this is a class extension I don't think I can respond to edit events as I can't get an instance of the editor (because the extension is application-independent). This is why I'm thinking of (worst case) creating a command add-in that can respond to edit events –  tomfumb Oct 28 '11 at 18:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.