# Can't create child nodes when providing parent HID

**URL:** <https://forum.techsoft3d.com/t/cant-create-child-nodes-when-providing-parent-hid/1299>\
**Category:** HOOPS Visualize Web\
**Created:** [January 13, 2023, 9:13pm UTC](https://forum.techsoft3d.com/t/cant-create-child-nodes-when-providing-parent-hid/1299 "2023-01-13T21:13:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mark.aronin](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@mark.aronin](https://forum.techsoft3d.com/u/mark.aronin)\
**Post date:** [January 13, 2023, 9:13pm UTC](https://forum.techsoft3d.com/t/cant-create-child-nodes-when-providing-parent-hid/1299/1 "2023-01-13T21:13:31Z")

</div>

Hello!

I’ve been trying to create a [createMeshInstance](https://docs.techsoft3d.com/communicator/latest/api_ref/viewing/classes/Communicator.Model.html?highlight=createmeshinstance#Communicator.Communicator.Model.createMeshInstance) and providing a MeshInstanceData and the parent node as the second argument.

I keep getting a `Assertion failed: console.assert` error in console.

Is there an example I can follow on how to created nested meshes? I can’t seem to do more than 2 level nesting.

Here’s a code snippet:

```auto
function createMeshDataFromPoint(pPoint) {
    const meshData = new Communicator.MeshData();
    meshData.setFaceWinding(Communicator.FaceWinding.Clockwise);
    meshData.setBackfacesEnabled(true);
    meshData.addPolyline([0, 0, 0, pPoint.x, pPoint.y, pPoint.z]);
    return meshData;
  }

async function createMeshInstance(pParentNode) {
    const pModel = communicator.model // <- provide the model here
    const meshX = await pModel.createMesh(this.createMeshDataFromPoint(new Communicator.Point3(10, 0, 0)));
    const nodeX = await pModel.createMeshInstance(new Communicator.MeshInstanceData(meshX, new Communicator.Matrix(), "aaaaaaa2"), pParentNode);
    await pModel.setNodesLineColor([nodeX], Communicator.Color.red());
    return nodeX;
}

const parentNode1 = await createMeshInstance(-2);
const parentNode2 = await createMeshInstance(parentNode1); // Gives assert error

```

Error:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/techsoft3d/original/1X/a8a7fc602461031fb9a142bee1cca17ae55367af.png)

Am I missing something?

EDIT: With some further investigating, I found out that BodyInstances can’t have child nodes, only PartIstances. So is there a way to create a PartInstance and add my meshes to it as child nodes?

---

<div class="post-metadata">

**Author:** ![guido](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.techsoft3d.com/guido/32/115_2.png) [@guido](https://forum.techsoft3d.com/u/guido)\
**Post date:** [January 13, 2023, 10:44pm UTC](https://forum.techsoft3d.com/t/cant-create-child-nodes-when-providing-parent-hid/1299/2 "2023-01-13T22:44:11Z")

</div>

Hi,

only meshes/bodies can be instanced in HOOPS Communicator, there is no way to instance nested hierarchies. This is by design and has been done mainly for performance reasons and to avoid a lot of complexity around how to handle attribute inheritance with instanced hierarchies. This means that if you want to instance a subhierachy in the viewer, you have to duplicate the nodes that the hierarchy consists of and only instance the actual meshes (via createMeshInstance) at the leaf nodes.

I hope this makes things a bit more clear.
