How do I delete a node based on its ID ?For example, I now want to delete all nodes of type XXX in the diagram.How can this be done?
You can do that via the element registry. Either by id
const elementRegistry = modeler.get("elementRegistry");
const startEvent = elementRegistry.get("StartEvent_1");
or by type
import { is } from "bpmn-js/lib/util/ModelUtil.js";
const events = elementRegistry.filter((element) => is(element, "bpmn:Event"));
And then delete the elements via the modeling API.
const modeling = modeler.get("modeling");
modeling.removeElements(events);
2 Likes