Site Tools


Differences

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

Link to this comparison view

developer:sdksamples:cplaneview [2015/09/14] (current)
Line 1: Line 1:
 +====== How To: Set a CPlane to a View ======
 +====== C++, .NET ======
 +> **Summary:​** //​Demonstrates how to set the construction plane in the active viewport parallel to the view.//
 +===== C++ =====
 +<code c++>
 +CRhinoCommand::​result CCommandTest::​RunCommand(
 +        const CRhinoCommandContext&​ context )
 +{
 +  CRhinoCommand::​result rc = CRhinoCommand::​cancel;​
 +
 +  // Get the active view object
 +  CRhinoView* view = ::​RhinoApp().ActiveView();​
 +  if( view )
 +  {
 +    // Get reference to the view's viewport object
 +    CRhinoViewport&​ vp = view->​Viewport();​
 +    // Create plane object based on viewport parameters
 +    ON_Plane plane( vp.Target(),​ vp.VP().CameraX(),​ vp.VP().CameraY() );
 +    // Copy viewport'​s cplane object
 +    ON_3dmConstructionPlane cplane = vp.ConstructionPlane();​
 +    // Set the cplane'​s plane object
 +    cplane.m_plane = plane;
 +    // Push the new cplane onto the cplane stack
 +    view->​Viewport().PushConstructionPlane( cplane );
 +    // Redraw the view
 +    view->​Redraw();​
 +    rc = CRhinoCommand::​success;​
 +  }
 +  return rc;
 +}
 +</​code>​
 +===== VB.NET =====
 +<code vb>
 +Public Overrides Function RunCommand(ByVal context As IRhinoCommandContext) _
 +  As IRhinoCommand.result
 +
 +  Dim rc As IRhinoCommand.result = IRhinoCommand.result.cancel
 +  ' Get the active view object
 +  Dim view As MRhinoView = RhUtil.RhinoApp.ActiveView
 +  If (view IsNot Nothing) Then
 +    ' Get reference to the view's viewport object
 +    Dim vp As MRhinoViewport = view.ActiveViewport()
 +    ' Create plane object based on viewport parameters
 +    Dim plane As New OnPlane(vp.Target(),​ vp.VP().CameraX(),​ vp.VP.CameraY())
 +    ' Copy viewport'​s cplane object
 +    Dim cplane As New On3dmConstructionPlane(vp.ConstructionPlane())
 +    ' Set the cplane'​s plane object
 +    cplane.m_plane = plane
 +    ' Push the new cplane onto the cplane stack
 +    view.ActiveViewport().PushConstructionPlane(cplane)
 +    ' Redraw the view
 +    view.Redraw()
 +    rc = IRhinoCommand.result.success
 +  End If
 +  Return rc
 +End Function
 +</​code>​
 +===== C# =====
 +<code c#>
 +public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
 +{
 +  IRhinoCommand.result rc = IRhinoCommand.result.cancel;​
 +  // Get the active view object
 +  MRhinoView view = RhUtil.RhinoApp().ActiveView();​
 +  if( view != null )
 +  {
 +    // Get reference to the view's viewport object
 +    MRhinoViewport vp = view.ActiveViewport();​
 +    // Create plane object based on viewport parameters
 +    OnPlane plane = new OnPlane( vp.Target(),​ vp.VP().CameraX(),​ vp.VP().CameraY() );
 +    // Copy viewport'​s cplane object
 +    On3dmConstructionPlane cplane = new On3dmConstructionPlane(vp.ConstructionPlane());​
 +    // Set the cplane'​s plane object
 +    cplane.m_plane = plane;
 +    // Push the new cplane onto the cplane stack
 +    view.ActiveViewport().PushConstructionPlane( cplane );
 +    // Redraw the view
 +    view.Redraw();​
 +    rc = IRhinoCommand.result.success;​
 +  }
 +  return rc;
 +}
 +
 +</​code>​
 +
 +
 +{{tag>​Developer cplusplus dotnet}}
  
developer/sdksamples/cplaneview.txt ยท Last modified: 2015/09/14 (external edit)