Hello CAB,
I do not understand your question, perhaps because of my bad English.
Interests me, retrieve, some objects xdata, before they are deleted.
Honestly, the code you posted has been considerably modified to fit my context.
I preferred not to include here all the code to avoid confusion.
The user can select multiple objects at once, I would like the function, realizes that among these objects there are one or more VIEPORT and then simply deleting them, for other objects (LINE, ARC, LWPOLYLINE, etc..) Function must, instead, return the xdata.
I hope it's clear now otherwise do not hesitate to ask.