developer:sdksamples:addcage


Creating NURBS Cage Objects

Developer: C++
Summary: Demonstrates how to create a NURBS Cage objects using the Rhino SDK.

Question

I would like to programatically add a NURBs cage object to the document using a plug-in. How can this be accomplished?

Answer

See the following sample code.

C++

CRhinoCommand::result CCommandFooBar::RunCommand( const CRhinoCommandContext& context )
{
  ON_3dPoint box_corners[8];
  CArgsRhinoGetBox args;
 
  CRhinoCommand::result rc = RhinoGetBox( args, box_corners, 0 );
  if( rc == CRhinoCommand::success )
  {
    int degree[3] = {3,3,3};   // defaults
    int cv_count[3] = {4,4,4}; // defaults
 
    ON_NurbsCage nurbs_cage;
    if( nurbs_cage.Create( box_corners,
        degree[0]+1, degree[1]+1, degree[2]+1,
        cv_count[0], cv_count[1], cv_count[2]) 
        )
    {
      CRhinoCageObject* cage_object = new CRhinoCageObject();
      if( cage_object )
      {
        cage_object->SetCage( nurbs_cage );
        context.m_doc.AddObject( cage_object );
        context.m_doc.Redraw();
      }
    }
  }
 
  return rc;
}


developer/sdksamples/addcage.txt · Last modified: 2010/03/11 12:35 by dale Driven by DokuWiki Recent changes RSS feed

 © 1997-2010 

McNeel North America Europe Latin AmericaAsia