Hide sub process element by default when creating it programatically


using the autoPlace from the bpmn library(you can tell from the code)


i was able to find the solution, not sure its the best one, but it works.

before i start creating the sub process children,i cache the sub process bounds and position, same thing for its incoming and outgoing connections.

        const position = {x: element.x , y: element.y };
        const size = {width: element.width, height: element.height};
        const outgoingConnection = element.outgoing[0];
        const outgoingConnectionWayPoints = outgoingConnection.waypoints;
        Object.assign(context, {outgoingConnection, outgoingConnectionWayPoints, size, position});
        let incomingConnection,incomingConnectionWayPoints;
        if (element.incoming.length > 0) {
            incomingConnection = element.incoming[0];
            incomingConnectionWayPoints = incomingConnection.waypoints;
            Object.assign(context, {incomingConnection, incomingConnectionWayPoints});

after finishing the creation and re apply this data using:

this.modeling.resizeShape to fix the size
and update the waypoints of the connections:

  this.modeling.updateWaypoints(context.outgoingConnection, context.outgoingConnectionWayPoints);
   if (context.element.incoming.length > 0) {
        this.modeling.updateWaypoints(context.incomingConnection, context.incomingConnectionWayPoints);