Site Tools


Differences

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

Link to this comparison view

developer:sdksamples:addobjectstogroup [2015/09/14] (current)
Line 1: Line 1:
 +====== Adding Objects to a Group ======
 +> **Developer:​** //​[[developer:​cplusplusplugins|C++]]//​
 +> **Summary:​** //​Demonstrates how to add selected objects to an object group.//
 +
 +The following code sample demonstrates how to add selected objects to an object group using the Rhino SDK.
 +
 +===== C++ =====
 +<code c++>
 +CRhinoCommand::​result CCommandTest::​RunCommand(const CRhinoCommandContext&​ context)
 +{
 +  CRhinoGetObject go;
 +  go.SetCommandPrompt( L"​Select objects to group" );
 +  go.EnableGroupSelect();​
 +  go.GetObjects(1,​0);​
 +  if( go.CommandResult() != CRhinoCommand::​success )
 +    return go.CommandResult();​
 +
 +  int i = 0, count = go.ObjectCount();​
 +  ON_SimpleArray<​const CRhinoObject*>​ members( count );
 +
 +  for( i = 0; i < count; i++ )
 +    members.Append( go.Object(i).Object() );
 +
 +  int index = context.m_doc.m_group_table.AddGroup( ON_Group(), members );
 +  context.m_doc.Redraw();​
 +  return (index >= 0) ? CRhinoCommand::​success : CRhinoCommand::​failure;​
 +}
 +</​code>​
 +
 +\\
 +
 +{{tag>​Developer cplusplus}}
  
developer/sdksamples/addobjectstogroup.txt ยท Last modified: 2015/09/14 (external edit)