McNeel Wiki
Adding Arrowheads to Curves
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

Is there anyway to add an arrowhead to a line using the SDK?

Answer

Arrowheads can be added to any curve object by simply modifying the curve object's attributes, or ON_3dmObjectAttributes. By modifying the attribute's m_object_decoration field, you can specify arrowheads on the start, end, or both ends of a curve object. The following example code illustrates this.

C++

  CRhinoCommand::result CCommandTest::RunCommand( const CRhinoCommandContext& context )
  {
    // Define a line
    ON_Line line;
    line.from = ON_3dPoint(0, 0, 0);
    line.to = ON_3dPoint(10, 0, 0);


    // Make a copy of Rhino's default object attributes
    ON_3dmObjectAttributes attribs;
    context.m_doc.GetDefaultObjectAttributes( attribs );


    // Modify the object decoration style
    //attribs.m_object_decoration = ON::no_object_decoration;
    //attribs.m_object_decoration = ON::start_arrowhead;
    //attribs.m_object_decoration = ON::end_arrowhead;
    attribs.m_object_decoration = ON::both_arrowhead;


    // Create a new curve object with our attributes
    context.m_doc.AddCurveObject( line, &attribs );
    context.m_doc.Redraw();


    return CRhinoCommand::success;
  }

C#

  public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
  {
    // Define a line
    OnLine line = new OnLine();
    line.from = new On3dPoint(0, 0, 0);
    line.to = new On3dPoint(10, 0, 0);


    // Make a copy of Rhino's default object attributes
    On3dmObjectAttributes attribs = new On3dmObjectAttributes();
    context.m_doc.GetDefaultObjectAttributes(ref attribs);


    // Modify the object decoration style
    //attribs.m_object_decoration = IOn.object_decoration.no_object_decoration;
    //attribs.m_object_decoration = IOn.object_decoration.start_arrowhead;
    //attribs.m_object_decoration = IOn.object_decoration.end_arrowhead;
    attribs.m_object_decoration = IOn.object_decoration.both_arrowhead;


    // Create a new curve object with our attributes
    context.m_doc.AddCurveObject(line, attribs);
    context.m_doc.Redraw();


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