McNeel Wiki
Enabling Orthogonal Mode
edit · print · help · all topics
Main Pages

AccuRender

Bongo

Brazil r/s

Developer

Flamingo

Penguin

Rhino Blogs

Rhino

Search

Languages

Česky

Deutsch

English

Español

Français

Italiano

Polish

日本語

한국어

中文(繁體)

 
.
DeveloperC++, .NET
VersionRhino 4

Question

How do you enable othro from the .Net SDK? I am trying to draw a line and I need ortho enabled programatically.

Answer

The state of Rhino's orthogonal drawing mode is stored in Rhino's application settings, or it's CRhinoAppSettings object. To check the current state of ortho, call CRhinoAppSettings::Ortho. To enable or disable ortho, call CRhinoAppSettings::EnableOrtho and pass in the boolean value that is appropriate. For more information on this and Rhino's application settings class, see rhinoSdkAppSettings.h. The following code illustrates how to use this feature:

C++

  CRhinoCommand::result CCommandTest::RunCommand(const CRhinoCommandContext& context)
  {
    CRhinoGetPoint gp;
    gp.SetCommandPrompt(L"Starting point");
    gp.GetPoint();
    if (gp.CommandResult() != success)
      return gp.CommandResult();


    ON_3dPoint start_point = gp.Point();


    CRhinoAppSettings& settings = RhinoApp().AppSettings();
    bool bOldValue = settings.Ortho();
    if (bOldValue == false)
      settings.EnableOrtho(true);


    gp.SetCommandPrompt(L"Ending point");
    gp.SetBasePoint(start_point);
    gp.DrawLineFromPoint(start_point, true);
    gp.GetPoint();


    if (bOldValue != settings.Ortho())
      settings.EnableOrtho(bOldValue);


    if (gp.CommandResult() != success)
      return gp.CommandResult();


    ON_3dPoint end_point = gp.Point();


    ON_Line line(start_point, end_point);
    context.m_doc.AddCurveObject(line);
    context.m_doc.Redraw();


    return success;
  }

C#

  public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
  {
    MRhinoGetPoint gp = new MRhinoGetPoint();
    gp.SetCommandPrompt("Starting point");
    gp.GetPoint();
    if (gp.CommandResult() != IRhinoCommand.result.success)
      return gp.CommandResult();


    On3dPoint start_point = gp.Point();


    MRhinoAppSettings settings = RhUtil.RhinoApp().AppSettings();
    bool bOldValue = settings.Ortho();
    if (bOldValue == false)
      settings.EnableOrtho(true);


    gp.SetCommandPrompt("Ending point");
    gp.SetBasePoint(start_point);
    gp.DrawLineFromPoint(start_point, true);
    gp.GetPoint();


    if (bOldValue != settings.Ortho())
      settings.EnableOrtho(bOldValue);


    if (gp.CommandResult() != IRhinoCommand.result.success)
      return gp.CommandResult();


    On3dPoint end_point = gp.Point();


    OnLine line = new OnLine(start_point, end_point);
    context.m_doc.AddCurveObject(line);
    context.m_doc.Redraw();


    return IRhinoCommand.result.success;
  }
rename · changes · history · subscriptions · lost and found · references · file upload