Hi
I am trying to convert my ArcObjects 9.3.1 code to 10. I have a simple button that when clicked creates a new shapefile & adds it to the TOC. It then starts the editor & selects the Sketch Tool.
The user then draws a polygon and the OnSketchEventHanlder then calculates the selected area the user just drew on the new shapefile. This is simple stuff but it wont work in ArcMap 10. Now I have to contend with what looks like templates & shapeconstructors. Ive managed to create a new template & add it to the template array, but I have no idea how to specifiy the editor to use the polygon construtor tool. The editor starts but the new shapefile is not selected & the polygon tools is not selected. How do I get it to use my template & use the polygon tool? Do i even need to do it this way with version 10? I see you can create a temporary feature within a template so I may not even need to create the new shapefile to use for editing???
Here's what I have so far
internal static IEditor get_Editor(IApplication application)
{
IEditor editor = null;
UID uidEditor = new UIDClass();
uidEditor.Value = "esriEditor.Editor";
editor = application.FindExtensionByCLSID(uidEditor) as IEditor;
return editor;
}
internal static void StartEditing(IApplication application, string layerName)
{
IEditor3 editor = get_Editor(application) as IEditor3;
//find the layer to edit
IMxDocument mxDocument = (IMxDocument)application.Document;
IFeatureLayer featureLayer = (IFeatureLayer)get_Layer(mxDocument, layerName);
//check for existing templates & remove
editor.RemoveAllTemplatesInLayer(featureLayer);
//create a single template for the editable layer
IEditTemplateFactory editTemplateFactory = new EditTemplateFactoryClass();
IEditTemplate editTemplate = editTemplateFactory.Create("PolygonAreaTemplate", featureLayer);
//Add the template
IArray templateArray = new ArrayClass();
templateArray.Add(editTemplate);
editor.AddTemplates(templateArray);
//Need some more code here use my template & use the polygon constructor tool
IDataset dataset = (IDataset)featureLayer.FeatureClass;
editor.StartEditing(dataset.Workspace);
}
Cheers
Tony