Site Tools


Differences

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

Link to this comparison view

developer:sdksamples:addcylinder [2015/09/14] (current)
Line 1: Line 1:
 +====== Add a Cylinder to Rhino ======
 +> **Developer:​** //​[[developer:​cplusplusplugins|C++]]//​
 +> **Summary:​** //​Demonstrates how to create a cylinder using **ON_BrepCylinder** and add it to Rhino.//
  
 +For more information on the **ON_BrepCylinder** function, see it's definition in opennurbs_brep.h.
 +
 +===== C++ =====
 +<code c++>
 +CRhinoCommand::​result CCommandTest::​RunCommand( const CRhinoCommandContext&​ context )
 +{
 +  ON_3dPoint center_point( 0.0, 0.0, 0.0 );
 +  double radius = 5.0;
 +  ON_3dPoint height_point( 0.0, 0.0, 10.0 );
 +  ON_3dVector zaxis = height_point - center_point;​
 +  ON_Plane plane( center_point,​ zaxis );
 +  ON_Circle circle( plane, radius );
 +  ON_Cylinder cylinder( circle, zaxis.Length() );
 +  ON_Brep* brep = ON_BrepCylinder( cylinder, TRUE, TRUE );
 +  if( brep )
 +  {
 +    CRhinoBrepObject* cylinder_object = new CRhinoBrepObject();​
 +    cylinder_object->​SetBrep( brep );
 +    if( context.m_doc.AddObject(cylinder_object) )
 +      context.m_doc.Redraw();​
 +    else
 +      delete cylinder_object;​
 +  }
 +
 +  return CRhinoCommand::​success;​
 +}
 +</​code>​
 +
 +{{tag>​Developer cplusplus}}
developer/sdksamples/addcylinder.txt ยท Last modified: 2015/09/14 (external edit)