# New childs added to PShape after being displayed once won't show

**URL:** <https://discourse.processing.org/t/new-childs-added-to-pshape-after-being-displayed-once-wont-show/40963>\
**Category:** Processing\
**Tags:** homework\
**Created:** [February 19, 2023, 4:55pm UTC](https://discourse.processing.org/t/new-childs-added-to-pshape-after-being-displayed-once-wont-show/40963 "2023-02-19T16:55:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sem](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@sem](https://discourse.processing.org/u/sem)\
**Post date:** [February 19, 2023, 4:55pm UTC](https://discourse.processing.org/t/new-childs-added-to-pshape-after-being-displayed-once-wont-show/40963/1 "2023-02-19T16:55:19Z")

</div>

Hello, in my sketch i continuesly add PShape childs to a group, but once i draw the group the newly added childs wont show up anymore, does anyone have a solution for this, or a workaround. I’d be very much appreciated.

below is an example, in my original code the problem occurs when i temporary add a child to the group when i press the mouseButton. perhaps this info is usefull.

Also, in my original code the group is quite large, and instead of just not showing the newly added childs, it crashes and gives the following error ‘BufferOverflowException’. Its also in 3d, but i dont know if that matters…

```auto
PShape shape;

void setup(){
  size(400, 400, P2D);
  
  frameRate(1);
  
  shape = createShape(GROUP);
}

void draw(){
  shape.addChild(createShape(RECT, random(0, width - 20), random(0, height - 20), 20, 20));
  
  if(mousePressed) shape(shape);
  
  println(frameCount);
}

```

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [February 19, 2023, 7:02pm UTC](https://discourse.processing.org/t/new-childs-added-to-pshape-after-being-displayed-once-wont-show/40963/2 "2023-02-19T19:02:45Z")

</div>

Hello @sem,

This code below works in Processing 3.5.4 but does NOT work as expected in Processing 4.1.3

```auto
PShape shape;

void setup()
  {
  size(400, 400, P3D);
  
  shape = createShape(GROUP);
  
  // Test to see if it worked in setup()
  for (int j=0; j<10; j++)
    {
    stroke(0, 255, 0);
    strokeWeight(3);
    mousePressed();
    }
  }

void draw()
  {
  background(255);
  stroke(255, 0, 0);
  strokeWeight(3);
  shape(shape);
  }

void mousePressed()
  {  
  shape.addChild(createShape(RECT, random(0, width - 20), random(0, height - 20), 20, 20));
  }
  

```

Processing 3.5.4 output:

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/5/2/5251023d8894c03c6e821d7306e5b620383310d3.png)

Processing 4.1.3 output:

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/2/9/29b269bb945f21a48d20b298b870d49bd4789063.png)

`:)`
