Site Tools


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

Link to this comparison view

developer:sdksamples:setviewname [2015/09/14] (current)
Line 1: Line 1:
 +====== Setting a Viewport'​s Title ======
 +> **Developer:​** //​[[developer:​cplusplusplugins|C++]],​ [[developer:​rhinocommon|RhinoCommon]]//​
 +> **Summary:​** //​Demonstrates how to set the title of a viewport.//
 +> **NOTICE:** //This sample has been moved [[developer:​rhinocommonsamples:​setviewname|here]]//​
 +How can I change the name, or title, or a viewport using the the Rhino SDK? For example, I would like to rename the "​Front"​ viewport to say "​Facade"​.
 +To change the title of a viewport, use **CRhinoViewport::​SetName**,​ or **MainViewport.Name** property in RhinoCommon. A Rhino view contains a "main viewport"​ that fills the entire view client window. To get a view's main viewport, you can call **CRhinoView::​MainViewport** in C++, or **view.MainViewport** in RhinoCommon.
 +For example:
 +===== C++ =====
 +<code c++>
 +CRhinoView* view = RhinoApp().ActiveView();​
 +if (view)
 +  view->​MainViewport().SetName("​Facade"​);​
 +===== C# =====
 +<code c#>
 +public static Rhino.Commands.Result SetActiveViewTitle (Rhino.RhinoDoc doc)
 +  Rhino.Display.RhinoView view = doc.Views.ActiveView;​
 +  if (view == null)
 +    return Rhino.Commands.Result.Failure;​
 +    ​
 +  if (view != null)
 +    view.MainViewport.Name = "​Facade";​
 +===== VB.NET =====
 +<code vb>
 +Public Shared Function SetActiveViewTitle(doc As Rhino.RhinoDoc) As Rhino.Commands.Result
 + Dim view As Rhino.Display.RhinoView = doc.Views.ActiveView
 + If view Is Nothing Then
 + Return Rhino.Commands.Result.Failure
 + End If
 + If view IsNot Nothing Then
 + view.MainViewport.Name = "​Facade"​
 + End If
 +End Function
 +{{tag>​Developer cplusplus rhinocommon}}
developer/sdksamples/setviewname.txt ยท Last modified: 2015/09/14 (external edit)