Site Tools


Differences

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

Link to this comparison view

developer:rhinocommonsamples:setviewname [2015/09/14] (current)
Line 1: Line 1:
 +===== Sample: Setting a Viewport'​s Title =====
 +
 +===== C# =====
 +<code c#>
 +public class SetViewNameCommand : Command
 +{
 +  public override string EnglishName { get { return "​csSetViewName";​ } }
 +
 +  protected override Result RunCommand(RhinoDoc doc, RunMode mode)
 +  {
 +    var view = doc.Views.ActiveView;​
 +    if (view == null)
 +      return Result.Failure;​
 +   
 +    view.MainViewport.Name = "​Facade";​
 +    return Result.Success;​
 +  }
 +}
 +</​code>​
 +===== VB.NET =====
 +<code vb>
 +Public Class SetViewNameCommand
 +  Inherits Command
 +  Public Overrides ReadOnly Property EnglishName() As String
 +    Get
 +      Return "​vbSetViewName"​
 +    End Get
 +  End Property
 +
 +  Protected Overrides Function RunCommand(doc As RhinoDoc, mode As RunMode) As Result
 +    Dim view As Rhino.Display.RhinoView = doc.Views.ActiveView
 +    If view Is Nothing Then
 +      Return Rhino.Commands.Result.Failure
 +    End If
 +
 +    view.MainViewport.Name = "​Facade"​
 +    Return Result.Success
 +  End Function
 +End Class
 +d Namespace
 +</​code>​
 +===== Python =====
 +<code python>
 +from Rhino.Commands import *
 +import rhinoscriptsyntax as rs
 +from scriptcontext import doc
 +
 +def RunCommand():​
 +  view = doc.Views.ActiveView
 +  if view == None:
 +    return Result.Failure
 + 
 +  view.MainViewport.Name = "​Facade"​
 +  return Result.Success
 +
 +if __name__ == "​__main__":​
 +  RunCommand()
 +</​code>​
 +
 +{{tag>​Developer rhinocommon}}
  
developer/rhinocommonsamples/setviewname.txt ยท Last modified: 2015/09/14 (external edit)