DATAKIT has introduced the Dtk_NodeConnector, a new way to connect entities in the MainDoc context.
Before reading this How-to, you should be familiar with Dtk_NodeConnector and Dtk_MainDoc / Dtk_Component / Dtk_Node concepts. Here some links to these documentations:
DATAKIT API provides a Dtk_MainDoc .
It's a convenient way to handle multiples files/parts or heterogeneous CAD systems.
However, we can't store huge assembly data into memory. So Dtk_Component information are not stored entirely.
To retrieve information of a specific Dtk_Component the integrator has to call the Dtk_API::ReadComponent method.
If you want to handle extra Dtk_Component entity connections - From Component A to Component B -, keep in mind that if you switch Dtk_Component context - by calling Dtk_API::EndComponent / Dtk_API::ReadComponent calls -, you will reread the pointed physical file and do a full reading. It's very time-consuming.
In the same way, successive calls to Dtk_Node::GetXXXXPtr - for example Dtk_Node::GetBodyPtr() - methods will reread the wanted geometry. It's not always what you may expect.
To avoid this, DATAKIT provides you with some tools to access only once to your entities.
Let's get the sample case explained by this picture:
As illustrated, we have a 'Root Assembly' containing a 'Sub Assembly'.
This 'Sub Assembly' contains a 'Part' which has a FDT.
The 'Root Assembly' also contains a ModelDisplay which has a Dtk_NodeConnector pointing to the Part FDT.
Keep in mind that you can't reread the part component when you have the Dtk_NodeConnector in the Assembly context because it would increase dramatically the processing time.
So you should read the 'Part' Dtk_Component prior to read the 'Sub Assembly' one - and of course the 'Root Assembly' one -.
After the call To Dtk_API::ReadComponent( PartComponent ) you will be able to call the Dtk_Component::GetConnectorsPointingToThisComponent method.
It will provide you a list of all Dtk_NodeConnector pointing to the Part Component - including the ModelDisplay To FDT one -.
Once you have the Dtk_NodeConnector you can call the Dtk_API::ReadConnectedEntity method to retrieve directly the pointed EntityPtrs - 1 or several -.
You can alternatively use successively:
As an integrator, if you want to connect the ModelDisplay to the FDT you should tag in your context the provided entity to be referenced later.
Once your are in the 'Root Assembly' Dtk_Component and access to the ModelDisplay Dtk_Node , you can retrieve the connections starting from the node by calling the Dtk_Node::GetAssociatedEntities method.
It will provide you a Dtk_tab of Dtk_NodeConnector .
At this point you should ask in your database the entity previously read and related to the Dtk_NodeConnector data.
IMPORTANT: Don't compare the Dtk_NodeConnector directly because they can be different.
Compare only the data - Component PathID / NodeId / SubEntitieId -.
You should now be able to connect the ModelDisplay to the FDT in your database.