Universal Robots Forum

Remove auto inserted waypoint not working

Hi, I’m trying to create a MoveNode, and I want to remove the auto inserted waypoint, but the remove opeartion always returns false. Here is the code:

   public void createTree()
		ProgramModel model =  programAPI.getProgramModel();
		ProgramNodeFactory nf = model.getProgramNodeFactory();
		TreeNode root = model.getRootTreeNode(this);
		try {
			TreeNode treeNode = root.addChild(nf.createMoveNode());
		} catch (TreeStructureException e) {
			// TODO Auto-generated catch block

Funny fact…
If I use the method above called createTree() in the constructor in the contribution class:

public MyappProgramNodeContribution(MyAppProgramNodeView view, DataModel model, ProgramAPIProvider apiProvider, CreationContext context) {
this.view = view;
this.model = model;
this.programAPI = apiProvider.getProgramAPI();

  if (context.getNodeCreationType() == CreationContext.NodeCreationType.NEW) {

It will not delete anything at all with removeChild…
However if I place the code from createTree in the view, such as:

	public void openView() {
		ProgramModel model =  programAPI.getProgramModel();
		TreeNode root = model.getRootTreeNode(this);
		if(root.getChildren().size() <=0)

It works like a charm!