Hi! The idea of an element deletion + temporary transaction seems good for me. But source element must have a sketch in such case, e.g. source element should be a Floor, for example.
I think you need to improve your code: first of all, find sketch in ids list, get all model curves references, then find dimensions in this list and filter them - sketch dimensions must have references to sketch model curves (just compare stable representations)