McNeel Wiki
Shading Viewports
edit · print · help · all topics
Main Pages

AccuRender

Bongo

Brazil r/s

Developer

Flamingo

Penguin

Rhino Blogs

Rhino

Rhino Labs

Search

Languages

Česky

Deutsch

English

Español

Français

Italiano

Polish

日本語

한국어

中文(繁體)

中文(简体)

 
.
DeveloperC++, .NET
SummaryDemonstrates how to set a viewport to shaded display using the Rhino SDK.

Question

I would like to set the active viewport to shaded display from a plug-in command. How is this accomplished?

Answer

The following example code demonstrates how to shade a viewport using the Rhino SDK.

C++

  CRhinoCommand::result CCommandTest::RunCommand( const CRhinoCommandContext& context )
  {
    CRhinoView* view = RhinoApp().ActiveView();
    if( 0 == view )
      return CRhinoCommand::failure;


    ON::display_mode dm = view->ActiveViewport().DisplayMode();
    if( dm != ON::shaded_display )
    {
      view->ActiveViewport().SetDisplayMode( ON::shaded_display );
      context.m_doc.ViewModified( view );
      view->Redraw();
    }


    return CRhinoCommand::success;
  }

C#

  public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
  {
    MRhinoView view = RhUtil.RhinoApp().ActiveView();
    if( view == null )
      return IRhinoCommand.result.failure;


    IOn.display_mode dm = view.ActiveViewport().DisplayMode();
    if( dm != IOn.display_mode.shaded_display )
    {
      view.ActiveViewport().SetDisplayMode( IOn.display_mode.shaded_display );
      context.m_doc.ViewModified( view );
      view.Redraw();
    }


    return IRhinoCommand.result.success;
  }
Last Modified [10/3/2008] rename · changes · history · subscriptions · references · file upload