# Dynamic update primitive?

**URL:** <https://community.cesium.com/t/dynamic-update-primitive/15808>\
**Category:** CesiumJS\
**Created:** [October 22, 2021, 2:58am UTC](https://community.cesium.com/t/dynamic-update-primitive/15808 "2021-10-22T02:58:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zyy1987](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/zyy1987/32/3458_2.png) [@zyy1987](https://community.cesium.com/u/zyy1987)\
**Post date:** [October 22, 2021, 2:58am UTC](https://community.cesium.com/t/dynamic-update-primitive/15808/1 "2021-10-22T02:58:08Z")

</div>

I create polylineGeometry object，I want dynamic update polylineGeometry width property。

---

<div class="post-metadata">

**Author:** ![clementchdn](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/clementchdn/32/3458_2.png) [@clementchdn](https://community.cesium.com/u/clementchdn)\
**Post date:** [October 22, 2021, 9:46am UTC](https://community.cesium.com/t/dynamic-update-primitive/15808/2 "2021-10-22T09:46:55Z")

</div>

Hi @zyy1987,

Can you please share a code sample to show how you create the polylineGeometry ? I don’t think you can update its width dynamically if you are re using the primitives API

---

<div class="post-metadata">

**Author:** ![zyy1987](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/zyy1987/32/3458_2.png) [@zyy1987](https://community.cesium.com/u/zyy1987)\
**Post date:** [October 22, 2021, 10:21am UTC](https://community.cesium.com/t/dynamic-update-primitive/15808/3 "2021-10-22T10:21:24Z")

</div>

const polyline = new Cesim.PolylineGeometry({  
positions: coordinates,  
width: polylineWidth,  
});  
const geometry = new Cesim.GeometryInstance({  
id: ++objId,  
geometry: polyline,  
attributes: {  
show: new Cesim.ShowGeometryInstanceAttribute(true),  
color: currentColor,  
},  
});  
const primitive = scene.primitives.add(  
new Cesim.Primitive({  
geometryInstances: geometry,  
appearance: new Cesim.PolylineColorAppearance({  
flat: true,  
renderState: {  
depthTest: { enabled: false },  
},  
}),  
})  
);

i want in some scenarios, update the width.

---

<div class="post-metadata">

**Author:** ![clementchdn](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/clementchdn/32/3458_2.png) [@clementchdn](https://community.cesium.com/u/clementchdn)\
**Post date:** [October 22, 2021, 11:46am UTC](https://community.cesium.com/t/dynamic-update-primitive/15808/4 "2021-10-22T11:46:24Z")

</div>

Ok, I don’t think you can only update the width. So what you could do is either remove the instance and create a new one, or you can create several instances with different widths and hide / show the ones with the appropriate width using the getGeometryAttributes method.

```auto
let attributes = primitive.getGeometryInstanceAttributes(objId)
if (attributes) {
    attributes.show =
    Cesium.ShowGeometryInstanceAttribute.toValue(false)
 }

```

this will hide one instance

---

<div class="post-metadata">

**Author:** ![zyy1987](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/zyy1987/32/3458_2.png) [@zyy1987](https://community.cesium.com/u/zyy1987)\
**Post date:** [October 25, 2021, 5:45am UTC](https://community.cesium.com/t/dynamic-update-primitive/15808/5 "2021-10-25T05:45:00Z")

</div>

Thanks for reply!
