Set activeview to top view


#1

Hi,

I must set the activeview to the top view, and after get a capture to export the model from this view at jpg.

My doubt is, How Do I guarantee to set the view at top?

I’m working in c# with rhinocommon and with Spanish language, so i can´t use the field name to search the top view by name if I want translate the Plugin to others languages.

Thanks


(Dale Fugier) #2

One way is to search for the localized Top viewport:

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      Rhino.Display.RhinoView view = null;

      view = doc.Views.Find("Top", false); // en
      if (null == view)
        view = doc.Views.Find("Superior", false); // es
      if (null == view)
        view = doc.Views.Find("Dessus", false); // fr
      if (null == view)
        view = doc.Views.Find("Superiore", false); // it
      if (null == view)
        view = doc.Views.Find("Drauf", false); // de
      if (null == view)
        view = doc.Views.Find("Shora", false); // cz
      if (null == view)
        view = doc.Views.Find("Góra", false); // pl

      if (null == view)
      {
        RhinoApp.WriteLine("Unable to find Top viewport.");
        return Result.Nothing;
      }

      doc.Views.ActiveView = view;

      return Result.Success;
    }

Just keep in mind that a viewport labeled “Top” does not necessarily display a top view.


#3

You could also check that the view is a parallel view and then compare the view direction to Array(0,0,-1).

That way you are future-proof for any language.

I have not done that before, nor used python yet, so it would take me some time to fiddle out the correct code, but I am sure @dale or any other wizard could hack it down pretty quickly.


#4

Thanks a lot


#5

Yes, as a matter of fact, I would not even bother with view names, I would just set up the camera/target/projection, etc. the way you want it in the script. Views and viewports are notoriously hard to deal with in Rhino, given that viewport names can be different when localized and that the name of a viewport may not have anything to do with the actual view that’s in there…

–Mitch