Modify size of standard Rhino views?

I’m looking for a way to modify the layout/size of the standard Rhino views using the RhinoCommon API. I want to be able to programatically modify the vertical split ratio so that they look something like this:

Is this possible? I’ve searched high and low through the documentation but I haven’t found anything.

You probably want to look at RhinoViewport.Size (for V5 and for V6, current Beta)

I’ve tried modifying RhinoViewport.Size on each of the active viewports and it has no effect on the view panes, only the internal viewport so I get some weird looking stuff like this:

Is there something extra I need to do? Here’s my code:

public static void SetVerticalSplitRatio(double left, double right)
{
    var topView = Doc.Active.Views.Find("top", false);
    var perspectiveView = Doc.Active.Views.Find("perspective", false);

    var clientWidth = topView.ActiveViewport.Size.Width +
                      perspectiveView.ActiveViewport.Size.Width;

    foreach (var view in Doc.Active.Views.GetStandardRhinoViews())
    {
        var viewportName = view.ActiveViewport.Name.ToLower();
        var viewSize = view.ActiveViewport.Size;

        if (viewportName == "top" || viewportName == "front")
            viewSize.Width = (int)(left * clientWidth / (left + right));
        else
            viewSize.Width = (int)(right * clientWidth / (left + right));

        view.ActiveViewport.Size = viewSize;
    }
}

Hi @david.browne,

I should have pointed you to RhinoView.Size instead.

For instance

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
	var av = doc.Views.ActiveView;
	av.Size = new System.Drawing.Size(20, 20);
	return Result.Success;
}

Results in

Thanks @nathanletwory but I can’t see and Size property on the RhinoView. I’m using Rhino 5 if that’s of any consequence.

image

Right, the documentation also doesn’t show it for v5. I don’t know of any other way, maybe @dale knows a way.

Hi @david.browne,

The SDK does not provide a way of problematically moving the viewport splitter.

This is the first request for this. Why do you need to do this? What problem does this help you solve?

– Dale

Hi @dale

My plugin is an application-specific tool for processing existing models. One of the processes involves the user aligning one component to another using UI controls. The view that is most critical for manually sighting this alignment is the front view, so I’d like to make this nice and big to reduce the chance of error. I would just maximize the view but it’s also important that they have some visibility on the top and perspective views during the process to verify other aspects of the alignment. Do you have any suggestions on how I may achieve a similar outcome? Even being able to set two horizontal views like this would be good:

Hi @david.browne,

If you are willing to write C++ code, then here is an example of how to make your own 2View command.

https://github.com/mcneel/rhino-developer-samples/blob/6/cpp/SampleCommands/cmdSample2View.cpp

– Dale

Hello,

Someone solutioned that? I need to resize the views and cannot do it.

System.Drawing.Size sizeView = new System.Drawing.Size(v.ActiveViewport.Size.Width * 2, v.ActiveViewport.Size.Height * 2);
v.ActiveViewport.Size = sizeView;
v.Redraw();

If I do debug, the size changes in the code, but later, in Rhino, the size view is the same before these lines.

Can someone help me?

Thanks,
Hector.

Hi @Hector_Gramaje,

Yeah, that isn’t going to be enough. In RhinoCommon, your best options is to script the ViewportProperties command.

– Dale

Hi @dale,

The problem is I need do it dynamically from code. Rhino isn’t interactive from my soft. The views size have to be fixed from code. That command opens a form for introducing values. Can I pass fixed values to this form from RhinoCommon.

Thanks,
Hector.

Hi @Hector_Gramaje,

Does this help?

https://github.com/mcneel/rhino-developer-samples/blob/6/rhinocommon/cs/SampleCsCommands/SampleCsViewportSize.cs

– Dale

1 Like

Hello @dale,

It isn’t enough, but it will help me a lot for find the right solution.

Thank you very much,
Hector.