# How create Subnode URCAP

**URL:** <https://forum.universal-robots.com/t/how-create-subnode-urcap/41441>\
**Category:** Java\
**Created:** [October 9, 2025, 5:24pm UTC](https://forum.universal-robots.com/t/how-create-subnode-urcap/41441 "2025-10-09T17:24:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vytor645](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/vytor645/32/7264_2.png) [@vytor645](https://forum.universal-robots.com/u/vytor645)\
**Post date:** [October 9, 2025, 5:24pm UTC](https://forum.universal-robots.com/t/how-create-subnode-urcap/41441/1 "2025-10-09T17:24:49Z")

</div>

Hello guys, I have onde question about childNode/subNode in URCAP, my code in actual moment:

```auto
public void addAproximacaoSubNode() {
    float[] poseArray = installationContribution.getCapturedPoseArray();
    undoRedoManager.recordChanges(() -> {
        try {
            ProgramNodeFactory factory = programModel.getProgramNodeFactory();
            TreeNode thisNode = programModel.getRootTreeNode(this);
            URCapProgramNode aproxNode = factory.createURCapProgramNode(AproximacaoNodeService.class);
            thisNode.addChild(aproxNode);
        
            AproximacaoNodeContribution childContribution = aproxNode.getAs(AproximacaoNodeContribution.class);
            if (childContribution != null) {
                childContribution.setPose(poseArray);
            } else {
               System.err.println("Erro: Interface AproximacaoNodeInterface não implementada no nó filho.");
           }
        } catch (TreeStructureException e) {
            System.err.println("Erro ao adicionar o subnó de aproximação.");
            e.printStackTrace();
        }
    });
}

```

error:

 ![imagem_2025-10-09_142223125](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/5/51d629792166aae4a3d0fbedd1247b84c03f9061.png)

the error is in line

```auto
  AproximacaoNodeContribution childContribution = aproxNode.getAs(AproximacaoNodeContribution.class);

```

I’m not able to call my subnode’s class, could anyone help me with a solution?

---

<div class="post-metadata">

**Author:** ![eric.feldmann](https://avatars.discourse-cdn.com/v4/letter/e/94ad74/32.png) [@eric.feldmann](https://forum.universal-robots.com/u/eric.feldmann)\
**Post date:** [October 9, 2025, 8:06pm UTC](https://forum.universal-robots.com/t/how-create-subnode-urcap/41441/2 "2025-10-09T20:06:07Z")

</div>

If I’m reading your stack trace right, it looks like it’s actually failing on addAproximacaoSubNode() (line 138) which would seem like it’s failing on

```auto
thisNode.addChild(aproxNode);

```

I would print the result of aproxNode just before that call and see if it’s coming back null or not. Regardless, I see what you’re trying to do and I don’t think it works that way. You have to implement a custom API interface to manipulate data in other nodes: [URCap Sample: URCap CustomAPI](https://forum.universal-robots.com/t/urcap-sample-urcap-customapi/3022)
