Site Tools


Differences

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

Link to this comparison view

developer:sdksamples:sublayer [2015/09/14] (current)
Line 1: Line 1:
 +====== Creating Sublayers ======
 +> **Developer:​** //​[[developer:​cplusplusplugins|C++]]//​
 +> **Summary:​** //​Demonstrates how to create sublayers using the Rhino SDK.//
 +
 +=====Question=====
 +I understand how to create new layers in Rhino, using the Rhino SDK. But, it is unclear to me how to create sublayers. Can you explain?
 +
 +=====Answer=====
 +Layers can be organized into a hierarchical structure, like file folders. If a layer has a parent layer, then the ON_Layer::​m_parent_layer_id member will be set to the id, or ON_Layer::​m_layer_id,​ of the parent layer. If the layer does not have a parent layer, then the ON_Layer::​m_parent_layer_id member will be set to ON_nil_uuud;​
 +
 +For example:
 +
 +===== C++ =====
 +<code c++>
 +
 +CRhinoCommand::​result CCommandTest::​RunCommand( const CRhinoCommandContext&​ context )
 +{
 +  CRhinoCommand::​result rc = CRhinoCommand::​failure;​
 +  CRhinoLayerTable&​ layer_table = context.m_doc.m_layer_table;​
 +
 +  ON_Layer layer;
 +  layer.m_name = L"​MyTestLayer";​
 +
 +  int layer_index = layer_table.AddLayer( layer );
 +  if( layer_index >= 0 | layer_index < layer_table.LayerCount() )
 +  {
 +    const CRhinoLayer&​ rhino_layer = layer_table[layer_index];​
 +
 +    ON_Layer sublayer;
 +    sublayer.m_name = L"​MyTestSubLayer";​
 +    sublayer.m_parent_layer_id = rhino_layer.m_layer_id;​
 +
 +    layer_index = layer_table.AddLayer( sublayer );
 +    if( layer_index >= 0 | layer_index < layer_table.LayerCount() )
 +      rc = CRhinoCommand::​success;​
 +  }
 +
 +  return rc;
 +}
 +
 +</​code>​
 +
 +{{tag>​Developer cplusplus}}
  
developer/sdksamples/sublayer.txt ยท Last modified: 2015/09/14 (external edit)