How to pass Frustum (ViewportInfo) to Frustum (ActiveViewport)?


I want to change the ActiveView Frustum properties by using something like this:

activeViewport = doc.Views.ActiveView.ActiveViewport
viewport_info = Rhino.DocObjects.ViewportInfo(activeViewport)
set_frustum = viewport_info.SetFrustum(-90, 90, -70, 70, 380, 510)
frustum0 = viewport_info.GetFrustum()
get_frustum = activeViewport.GetFrustum(frustum0)

But I get following error:

Message: GetFrustum() takes at most 6 arguments (1 given)

So I see, that frustum0 contains:

(True, -90, 90, -70, 70, 380, 510)

But when I pass these 6 values separately, I got:

Message: expected StrongBox[float], got float

What should I pass to the GetFrustum() to get it work?


(Dale Fugier) #2

Does this help?

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
  Rhino.Display.RhinoView view = doc.Views.ActiveView;
  if (null != view)
    Rhino.Display.RhinoViewport vp = view.ActiveViewport;

    Rhino.DocObjects.ViewportInfo vp_info = new ViewportInfo(vp);
    double left, right, bottom, top, near_distance, far_distance;
    vp_info.GetFrustum(out left, out right, out bottom, out top, out near_distance, out far_distance);
    // TODO...
    vp_info.SetFrustum(left, right, bottom, top, near_distance, far_distance);

    view.ActiveViewport.SetViewProjection(vp_info, true);

  return Result.Success;


Thanks Dale,
I use Python, but I get, that with SetViewProjection I can use vp_info. And it works.

One more question to frustum. I thought that when I set left, right, bottom and top values, I set them for frustum center point, but it seems, that they are set to near distance. I found that with use of ActiveViewport.GetNearRect (and GetFarRect).
Is that right? It’s quite strange for me, if it works this way.



@dale or anyone, do you have answer to my question regarding frustum center point left, right, bottom and top values?


(Steve Baer) #5

I believe left, right, top, and bottom are with respect to the near plane. Is that what you are asking about?


Yes Steve, that’s what I was asking about. Thanks.
It seems to me quite strange, why is it set for the near plane? Is there any reasonable explanation?

(Steve Baer) #7

Probably this


Great, thanks Steve!