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.

on ArcMap 9.3:

IEditLayers pEditLayers;
IFeatureLayer pFeatLayer;
IMap pMap = ((IMxDocument)Application.Document).FocusMap;
pEditLayers = (IEditLayers)Editor;
pMap = Editor.Map;
for (int i = 0; i < pMap.LayerCount; i++)
{
    if (pMap.get_Layer(i).Name == "roads")
    {
        pFeatLayer = (IFeatureLayer)pMap.get_Layer(i);
        pEditLayers.SetCurrentLayer(pFeatLayer, SubType);
    }
... 

in ArcMap 10: first idea, but it does not work:

IEditTemplate currentTemplate = m_editor.CurrentTemplate;
for (int i = 0; i < m_editor.TemplateCount -1; i++)
      {
        IEditTemplate editTemplate = m_editor.get_Template(i);
        if (editTemplate.Layer.Name == "roads")
        {
          currentTemplate = editTemplate;
        }
...
share|improve this question
add comment

2 Answers

You just need to set the template back through IEditor3.CurrentTemplate (in your code snippet, you are only updating the currentTemplate, which is a local variable).

IEditTemplate currentTemplate = m_editor.CurrentTemplate;
for (int i = 0; i < m_editor.TemplateCount - 1; i++)
{
    IEditTemplate editTemplate = m_editor.get_Template(i);
    if (editTemplate.Layer.Name == "roads")
    {
        currentTemplate = editTemplate;
        m_Editor.CurrentTemplate = currentTemplate; //  <----
    }
}
share|improve this answer
    
Thank you, petr k. Now it works! –  user2279 Mar 11 '11 at 9:03
add comment

I've probably been accessing it in a really painful manner, but I loop through the Editor's CurrentTemplate.Layer property by name:

String currentfeature = theEditor.CurrentTemplate.Layer.Name;
String[] curfeature = currentfeature.Split('.'); //to split the version name from the fc
if(curfeature.Length > 1)
{
     if(curfeature[1].Equals("Branch"))
          {
                //do the editor stuff
          }
}

It's brief, but I hope it helps. @10 is a confusing, tangled mess of changes to workflow.

best of luck

share|improve this answer
add comment

Your Answer

 
discard

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