In C++ I am trying to add child layers to a parent layer but so far without success.
I can add one, top layer by calling the function below with, for example:
wchar_t *layer_name = L"House Cloud"
int32_t add_layer(CRhinoDoc *pDoc, CRhinoLayerTable &layer_table, wchar_t *layer_name) {
// Does a layer with the same name already exist?
// layer_name = parent::child using ON_Layer::LayerNamePathDelimiter() for :: separator.
int32_t layer_index = layer_table.FindLayerFromFullPathName(layer_name, -1);
// If so delete it.
if (layer_index >= 0) {
// Get any objects on the layer
const CRhinoLayer &layer = layer_table[layer_index];
ON_SimpleArray<CRhinoObject*> obj_list;
int i, obj_count = pDoc->LookupObject(layer, obj_list);
// Delete all of the layer's objects.
CRhinoObject* obj; for (i = 0; i < obj_count; i++) { obj = obj_list[i]; pDoc->DeleteObject(obj); }
// Now remove the layer.
layer_table.DeleteLayer(layer_index, true); }
// Create a new layer for the graph.
ON_Layer layer; layer.SetName(layer_name);
// Add the layer to the layer table.
layer_index = layer_table.AddLayer(layer);
// If layer could not be added, layer index will be negative.
return layer_index;
}
but I cannot create a sublayer using:
wchar_t *layer_name = L"House Cloud::Kitchen Cloud"
The result is a layer with the hierarchical names flattened into one name: House Cloud::Kitchen Cloud
There must be a different way to do this.
Regards,
Terry.