Site Tools


Differences

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

Link to this comparison view

developer:sdksamples:addline [2015/09/14] (current)
Line 1: Line 1:
 +====== How To: Add a Line Curve Object ======
 +> **Developer:​** //​[[developer:​cplusplusplugins|C++]]//​
 +> **Summary:​** //​Demonstrates how to add a line curve to Rhino using the Rhino C++ SDK.//
 +
 +===== C++ =====
 +<code c++>
 +CRhinoCommand::​result CCommandTest::​RunCommand(const CRhinoCommandContext&​ context)
 +{
 +  CRhinoGetPoint gp;
 +  gp.SetCommandPrompt( L"​Start of line" );
 +  gp.GetPoint();​
 +  if( gp.CommandResult() != CRhinoCommand::​success )
 +    return gp.CommandResult();​
 +
 +  ON_3dPoint pt_start = gp.Point();
 +
 +  gp.SetCommandPrompt( L"End of line" );
 +  gp.SetBasePoint( pt_start );
 +  gp.DrawLineFromPoint( pt_start, TRUE );
 +  gp.GetPoint();​
 +  if( gp.CommandResult() != CRhinoCommand::​success )
 +    return gp.CommandResult();​
 +
 +  ON_3dPoint pt_end = gp.Point();
 +  ON_3dVector v = pt_end - pt_start;
 +  if( v.IsTiny() )
 +    return CRhinoCommand::​nothing;​
 +
 +  ON_Line line( pt_start, pt_end );
 +
 +  context.m_doc.AddCurveObject( line );
 +  context.m_doc.Redraw();​
 +
 +  return CRhinoCommand::​success;​
 +}
 +</​code>​
 +
 +{{tag>​Developer cplusplus}}
  
developer/sdksamples/addline.txt ยท Last modified: 2015/09/14 (external edit)