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 have an ArcObjects (9.3) Class Extension which has an event handler for OnCreate so that feature properties can be manipulated / assigned when a feature is first created.

Some of the functionality needs enclosing in an edit operation, which requires an IWorkspaceEdit object. As far as I know the only way I can get the IWorkspaceEdit is by getting the IEditor (extension) from IApplication, then grabbing the IEditor's EditWorkspace.

In an ArcObjects command (extending BaseCommand) I get the IApplication 'hook' passed on create (that is, the command's creation), so I can retain a reference to it. However, in the class extension's OnCreate method I am only passed the IObject which has been created. I can't see a way to get the IObject's workspace to work from that direction.

Can anybody please tell me

  1. How to access the calling IApplication from a class extension or,
  2. How to get an IObject's EditWorkspace or,
  3. Any other way to create an edit operation within a class extension's OnCreate method?

Any help very much appreciated.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

You can cast an IObject.Table to IDataset, then cast IDataset.Workspace to IWorkspaceEdit. If you only intend for people using a desktop app to edit the data, I agree with @Jamie that you consider an edit extension instead. The advantage of a class extension is that it will receive events even when used in a standalone (arcengine) application (though I've never tried this). For that reason, you should not have any dependencies on IApplication.

share|improve this answer
    
Thanks for the stepping stones, I'm going to have to use that approach for now as I'm bug-fixing with no scope for re-factoring. Also I've been told that if an editor extension is used there's no requirement for the extension to be installed when editing the data. The class extension means you can't even view the data without the DLL registered, which is a requirement in this case. –  tomfumb Oct 17 '11 at 17:50

I would recommend you make an editor extension if you want to manipulate editing events. Using the IWorkspaceEdit just adds complication. Here is a link to the ESRI editor extension help.

http://resources.esri.com/help/9.3/ArcGISDesktop/dotnet/930daa9a-89fe-4899-a7f4-dd1b520ad316.htm

share|improve this answer

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.