C++ Add layer changed syntax

Hi,

I am following this tutorial to add child layer, but the syntax of Current Rhino SDK was changed:

I tried to write something like this and I have one error in line
child_layer.SetParentLayerId(layer.Id);//Error C2276 '*': illegal operation on bound member function expression
also tried:
child_layer.SetParentLayerId = layer.Id; // Error C2659 = function as left operand

How can I correctly change parent layer id?

CRhinoCommand::result CCommandLearning180704::RunCommand(const CRhinoCommandContext& context)
{

	
	CRhinoLayerTable& layer_table = context.m_doc.m_layer_table;

	//Define parent layer
	ON_Layer parent_layer;
	parent_layer.SetName(L"Parent");

	//Add parent layer
	int parent_layer_index = layer_table.AddLayer(parent_layer);
	if (parent_layer_index >= 0) {
		//Get the layer we just added
		const CRhinoLayer& layer = layer_table[parent_layer_index];

		//Define child layer
		ON_Layer child_layer;
		child_layer.SetName(L"Child");

		//Assign parent layer's id as child's parent id
		child_layer.SetParentLayerId(layer.Id);//Error	C2276	'*': illegal operation on bound member function expression


		//Add child layer
		layer_table.AddLayer(child_layer);
	}
	
	return success;
}

probably you need to call a function layer.Id() or use member variable layer.m_layer_id

@Petras_Vestartas, I’ve updated the guide. Please revisit the page…

– Dale

Thanks Dale and Menno, the only issue was that I wrote: layer.Id isntead of layer.Id()

Each time I see id, count, or name it seems to me as variable but in c++ rhino sdk it is always a method.

method function :slight_smile:

It is a method

I stand corrected :slight_smile: