Site Tools


Differences

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

Link to this comparison view

developer:rhinocommonsamples:viewportresolution [2015/09/14] (current)
Line 1: Line 1:
 +===== Sample: Print Active Viewport Resolution =====
 +
 +===== C# =====
 +<code c#>
 +[System.Runtime.InteropServices.Guid("​75ED2D51-3633-4624-947A-02B15706D3F4"​)]
 +public class ViewportResolutionCommand : Command
 +{
 +  public override string EnglishName { get { return "​csViewportResolution";​ } }
 +
 +  protected override Result RunCommand(RhinoDoc doc, RunMode mode)
 +  {
 +    var activeViewport = doc.Views.ActiveView.ActiveViewport;​
 +    RhinoApp.WriteLine(String.Format("​Name = {0}: Width = {1}, Height = {2}", ​
 +      activeViewport.Name,​ activeViewport.Size.Width,​ activeViewport.Size.Height));​
 +    return Result.Success;​
 +  }
 +}
 +</​code>​
 +===== VB.NET =====
 +<code vb>
 +<​System.Runtime.InteropServices.Guid("​A58C34C4-AF2D-4426-9DDE-15754B6B5FEE"​)>​ _
 +Public Class ViewportResolutionCommand
 +  Inherits Command
 +  Public Overrides ReadOnly Property EnglishName() As String
 +    Get
 +      Return "​vbViewportResolution"​
 +    End Get
 +  End Property
 +
 +  Protected Overrides Function RunCommand(doc As RhinoDoc, mode As RunMode) As Result
 +    Dim activeViewport = doc.Views.ActiveView.ActiveViewport
 +    RhinoApp.WriteLine([String].Format("​Name = {0}: Width = {1}, Height = {2}", activeViewport.Name,​ activeViewport.Size.Width,​ activeViewport.Size.Height))
 +    Return Result.Success
 +  End Function
 +End Class
 +d Namespace
 +</​code>​
 +===== Python =====
 +<code python>
 +from scriptcontext import doc
 +
 +activeViewport = doc.Views.ActiveView.ActiveViewport
 +print "Name = {0}: Width = {1}, Height = {2}"​.format(
 +    activeViewport.Name,​ activeViewport.Size.Width,​ activeViewport.Size.Height)
 +</​code>​
 +
 +{{tag>​Developer rhinocommon}}
  
developer/rhinocommonsamples/viewportresolution.txt ยท Last modified: 2015/09/14 (external edit)