Change activeview event


#1

hi,
is there an event in Rhinocommon which raises when Doc.Views.ActiveView is changed by the user?

thanks


(Nathan 'jesterKing' Letwory) #2

Subscribe to the event Rhino.Display.RhinoView.SetActive.


#3

thanks Nathan, I tryed with that event but seems that it is raised only when the user is “getting out” from a detail view, not even when double clicking on it to enter in “model space”, neither navigating between layouts.
What I am looking for is an I an event to get raised when the user navigates from layout to layout (pageView to pageView)
thanks


(Nathan 'jesterKing' Letwory) #4

I’ll have to defer answering that to @dale.


(Dale Fugier) #6

@aitorleceta,

This seems to work for me:

public class TestAitorleceta : Command
{
  private bool m_enabled;

  public override string EnglishName => "TestAitorleceta";

  protected override Result RunCommand(RhinoDoc doc, RunMode mode)
  {
    if (m_enabled)
      RhinoView.SetActive -= OnSetActiveViewEventHandler;
    else
      RhinoView.SetActive += OnSetActiveViewEventHandler;

    m_enabled = !m_enabled;

    return Result.Success;
  }

  /// <summary>
  /// RhinoView.SetActive event handler
  /// </summary>
  public static void OnSetActiveViewEventHandler(object sender, ViewEventArgs e)
  {
    RhinoApp.WriteLine("Active view set to \"{0}\"", e.View.ActiveViewport.Name);
  }
}

– Dale