# URCap Custom NodeFactory

**URL:** <https://forum.universal-robots.com/t/urcap-custom-nodefactory/9904>\
**Category:** URCap Development\
**Created:** [November 12, 2020, 9:15am UTC](https://forum.universal-robots.com/t/urcap-custom-nodefactory/9904 "2020-11-12T09:15:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![marius.gheorghe](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@marius.gheorghe](https://forum.universal-robots.com/u/marius.gheorghe)\
**Post date:** [November 12, 2020, 9:15am UTC](https://forum.universal-robots.com/t/urcap-custom-nodefactory/9904/1 "2020-11-12T09:15:11Z")

</div>

Hey,  
I am working on a URCap with several Nodes and I would like to configure them before I insert them in the tree.  
Is it possible to have a custom ProgramNodeFactory for my Nodes? I have not found any examples and I cannot figure out a way looking through the API.

Currently, the solution I have is that my nodes implement my custom Api and then I can use that api after I insert the node.  
Example:

```
TreeNode treeNode = parent.addChild(nf.createURCapProgramNode(MyURCapService.class));
URCapProgramNode programNode = (URCapProgramNode) treeNode.getProgramNode();
MyURCapApi myApi = programNode.getAs(MyURCapApi.class); // only works after the node has been added to the tree
myApi.setFlag(true);

```

Is this the only way to do it? Or would the factory basically do the same thing anyway?

Thank you
