How to get the Viewport for an Animation - RhinoCommon

Hi - when rendering a Sun Study inside the following method…

override protected Result Render(RhinoDoc doc, RunMode mode, bool fastPreview)

…how do you determine the Viewport that was specified in the One Day Sun Animation panel? ie. The sun animation might be for the Perspective window, but the use has activated the Top view, so checking the doc.Views.ActiveView.ActiveViewport will be the Top view, not the Perspective view.

Thanks

Paul

Hi Paul,

I don’t believe there is any way to get to the data in the “One Day Sun Animation” panel. @rajaa do you know of a way?

– Dale

Thanks Dale (sorry for the late reply - didn’t get an email)

That seems like quite a shortcoming - would it be possible to add this to the RhinoCommon API pls?

Thanks

Paul

Hi Paul,

Just curious, why do you need this? If you were going a one day sun study, wouldn’t just set the current render plug-in and then run the study?

– Dale

Hi Dale - perhaps I am missing something here…how can a Rhino.PlugIns.RenderPlugIn plugin render without knowing the camera position? The camera position comes from the View - but there doesn’t seem any way to determine what View was specified for the sun study.

    override protected Result RenderWindow(
        RhinoDoc doc,
        RunMode modes,
        bool fastPreview,
        RhinoView view,
        Rectangle rect,
        bool inWindow)

looks like it might contain the View, but is never called.

Paul

Hi Paul,

If you put a breakpoint in your plug-in’s Render() override, you will see that this method is called, if your plug-in is the current render plug-in. In this case, just get the active view (as set by AnimationTools) using RhinoDoc.Views.ActiveView.

protected override Result Render(RhinoDoc doc, Commands.RunMode mode, bool fastPreview)
{
  var view = doc.Views.ActiveView;
  if (null != view)
  {
    // TODO...    
  }
  return Result.Success;
}

Thanks Dale - that’s exactly what I am doing, however it does not work. The doc.Views.ActiveView returns the currently selected viewport rather than the viewport selected in the SunStudy panel. The same problem exists for fly-thrus and Bongo animations. It’s an issue for all Rhino.PlugIns.RenderPlugIn’s.

Paul

@andy, any insight here?

The reason is that this is a bug in the animation tools. If you use RhinoRender, set the viewport to render in the sun study dialog to “Perspective”, select the “Front” viewport and record the animation, RhinoRender renders the view in the Front viewport.

It seems like the animation tools are not pre-setting the viewport correctly. This is something @rajaa will have to look into.

I don’t believe this happens for Bongo though - I certainly can’t repeat it here.

That makes sense. Thanks Andy.