| McNeel Wiki | |||||
| edit · print · help · all topics | |||||
Main Pages
Languages
| 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;
}
VB.NET (Rhino 4)
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
C# (Rhino 4)
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;
}
| ||||
| rename · changes · history · subscriptions · lost and found · references · file upload | |||||