Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developer:viewportresolution [2015/09/14] (current)
Line 1: Line 1:
 +====== Obtaining the Resolution of a Viewport ======
 +> **Developer:​** //​[[developer:​dotnetplugins|.NET]]//​
 +> **Summary:​** //​Demonstrates how to get the pixel resolution of a viewport.//
 +> **NOTICE:** //The Rhino.NET SDK is deprecated in Rhino 5.  This example adapted for the new RhinoCommon SDK is [[developer:​rhinocommonsamples:​viewportresolution|here]]//​
 +===== Question =====
 +I want know how to get the viewport resolution via the SDK. The language is
 +C#.
  
 +===== Example =====
 +
 +==== C# ====
 +<code c#>
 +public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
 +{
 +  MRhinoView view = RhUtil.RhinoApp().ActiveView();​
 +  if (null != view)
 +  {
 +    string name = view.ActiveViewport().Name();​
 +    int left = 0, right = 0, bottom = 0, top = 0;
 +    view.ActiveViewport().VP().GetScreenPort( ref left, ref right, ref bottom, ref top);
 +    int width = right - left;
 +    int height = bottom - top;
 +    RhUtil.RhinoApp().Print(string.Format("​Name = {0}: Width = {1}, Height = {2}\n",​ name, width, height));
 +  }
 +  return IRhinoCommand.result.cancel;​
 +}
 +</​code>​
 +
 +\\
 +
 +{{tag>​Developer dotnet}}
developer/viewportresolution.txt ยท Last modified: 2015/09/14 (external edit)