Get nodes & submodel in a submodel

The engine.
Post Reply
jdtoellner
Posts: 71
Joined: Mon Aug 01, 2016 9:45 pm

Get nodes & submodel in a submodel

Post by jdtoellner »

Is there a way to get a list of nodes and submodels that are in a submodel?

I looked through various properties and methods, especially in:

Code: Select all

theNet.GetSubmodelHandler().GetSubmodel(submodelHandle
I didn't find anything intuitively obvious.
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Get nodes & submodel in a submodel

Post by shooltz[BayesFusion] »

The methods to use are DSL_submodelHandler::GetIncludedNodes and GetIncludedSubmodels. Also, use DSL_submodelHandler::GetFirstSubmodel and GetNextSubmodel to iterate over all submodels in the network.

Code: Select all

DSL_submodelHandler &s = net.GetSubmodelHandler();

for (int h = s.GetFirstSubmodel(); h >= 0; h = s.GetNextSubmodel(h))
{
	printf("%d %s\n", h, s.GetSubmodel(h)->header.GetId());

	DSL_intArray a;
	s.GetIncludedNodes(h, a);
	for (int i = 0; i < a.NumItems(); i++)
	{
		printf("\t%d %s\n", a[i], net.GetNode(a[i])->GetId());
	}

	DSL_intArray b;
	s.GetIncludedSubmodels(h, b);
	for (int i = 0; i < b.NumItems(); i++)
	{
		printf("\t%d %s\n", b[i], s.GetSubmodel(b[i])->header.GetId());
	}
}
Post Reply