# GreasedLineMesh .setPoints() won't create additional lines?

**URL:** <https://forum.babylonjs.com/t/greasedlinemesh-setpoints-wont-create-additional-lines/49664>\
**Category:** Bugs\
**Created:** [April 15, 2024, 5:21am UTC](https://forum.babylonjs.com/t/greasedlinemesh-setpoints-wont-create-additional-lines/49664 "2024-04-15T05:21:36Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [April 16, 2024, 1:08pm UTC](https://forum.babylonjs.com/t/greasedlinemesh-setpoints-wont-create-additional-lines/49664/6 "2024-04-16T13:08:51Z")

</div>

I’ve decided not to automatically set the `widths` if the number of the points changes when the `setPoints` function is used. `setPoints` was intended to use when you want to move the existing line points. If you move the lines each frame, updating the widths will generate unnecessary overhead and the `setPoints`will still doesn’t know anything about the the newly added lines widths.

You’ll have to update the `widths` manually if you change the number of `points`.

However I’ve added a new helper function `GetPointsCount(points: number[][]): number` which will count the number of points. You can pass this value into the `CompleteGreasedLineWidthTable` function which will create the missing entries:

[https://doc.babylonjs.com/typedoc/modules/BABYLON#CompleteGreasedLineWidthTable](https://doc.babylonjs.com/typedoc/modules/BABYLON#CompleteGreasedLineWidthTable)

[https://doc.babylonjs.com/typedoc/enums/BABYLON.GreasedLineMeshWidthDistribution](https://doc.babylonjs.com/typedoc/enums/BABYLON.GreasedLineMeshWidthDistribution)

So your code will look like (sets the new lines upper and lower width to 2):

```javascript
    const pointsCount = BABYLON.GetPointsCount(myPoints);
    line2.widths = BABYLON.CompleteGreasedLineWidthTable(
        pointsCount, 
        line2.widths, 
        BABYLON.GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START, 
        2, 
        2);
    line2.addPoints(myPoints);

```

Or you can create the `widths` table manually according to your needs.

---

_[View the full topic](https://forum.babylonjs.com/t/greasedlinemesh-setpoints-wont-create-additional-lines/49664)._
