3

I want to:

  1. create new data frame,
  2. give it a name,
  3. activate it and then fill with layers, etc. in ArcMap .NET custom command.

With this code I achieve 1. and 2., but don't know how to activate it:

// mxDocument is IMxDocument
IMap newMap = mxDocument.Maps.Create();
newMap.Name = "I can name it as I want: " + Guid.NewGuid();
mxDocument.Maps.Add(newMap);
//HOW TO Activate newMap???
mxDocument.UpdateContents();

New data frame is created, added to TOC but how to make it active?

mxDocument.ActiveView.FocusMap = newMap

gives System.NotImplementedException.

EDIT: IMaps.Create() + IMaps.Add() is too primitive way to create a data frame, it won't work properly. See this link for a better description.

1
  • Is this question really supposed to have the Python tag? Feb 13, 2015 at 18:26

1 Answer 1

5

Try setting ActiveView (rather than FocusMap) to newMap:

mxDocument.ActiveView = newMap
1
  • Thanks, it worked (with a cast): mxDocument.ActiveView = (IActiveView)newMap. Feb 11, 2015 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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