Site Tools


Differences

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

Link to this comparison view

developer:sdksamples:addcage [2015/09/14] (current)
Line 1: Line 1:
 +======Creating NURBS Cage Objects======
 +> **Developer:​** //​[[developer:​cplusplusplugins|C++]]//​
 +> **Summary:​** //​Demonstrates how to create a NURBS Cage objects using the Rhino SDK.//
 +
 +=====Question=====
 +I would like to programatically add a [[rhino:​nurbs|NURBs]] cage object to the document using a plug-in. How can this be accomplished?​
 +
 +=====Answer=====
 +See the following sample code.
 +
 +==== C++ ====
 +<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;
 +}
 +</​code>​
 +
 +\\
 +
 +{{tag>​Developer cplusplus}}
  
developer/sdksamples/addcage.txt ยท Last modified: 2015/09/14 (external edit)