detaching is very undesirable, as I have tried that approach of recording the original data, and resetting afterwards.
Its ok on simple stuff, but anything complicated like nested items, or multiple viewports makes it really involved to do. It would be far, far, better to be able to change the attach flag via the API.