yes, i’m trying to do the same. And it’s a correct and easiest way to do. My problem, that I’m trying to get the element while it’s still not on the canvas. I need to use code that you write after model is on the canvas.
If I understand your requirement, you want set color when put a element on canvas, if this, I suggest use bpmn events like shape.create or commandStack.elements.create.postExecuted, in canvas when a shape created, this event fired and you can get element in creation and set color.
i’ve got elements with ID’s from server. And using ref’s for using Modeler. Main problem is from event loop, because my function for getting elements from ‘elementRegistry’ has been called and executed before elements rendered on canvas and they assigned to ‘elementRegistry’.