Hi,
I think you have two options.
The most clever and straightforward one:

Do the test before adding the object.
It is not required to add an object to an operation before one can preform some sort of testing.
Even when added to an operation, it will not yet be a drawing object than can be queried back for a test.
Everything you can do with an
RBlockReferenceEntity queried from the document can also be done before the operation.
Apart from that the queried object has a uniquely defined id.
Undo means undo the operation, essentially removing the drawing entity, setting it undone, but not removing the operation.
An operation in the operations stack can still be redone and undone again.
With more objects, for example to compare, collect them in an array:
Code: Select all
blockRefs = [];
...
// Creation of Block References:
....
// Collecting:
blockRefs.push(blockRef);
Preform the test(s) afterwards on the items in the array, keeping those that comply
One could set the array item to undefined when failed:
Also avoiding further testing based on not complying objects, undefined items.
Finally only adding the objects that did comply to all testing, are still defined:
Code: Select all
for (var i=0; i<blockRefs.length, i++)
if (!isNull(blockRefs[i]) {
op.addObject(blockRefs[i]);
}
}
di.applyOperation(op);
Another but dirty approach would be to create a clone and:
Dirty, because you will loose track of what will eventually make it as drawing entity.
Perhaps impossible because of a conflict between a new and a not yet defined id.
Still a bit uncharted, perhaps you don't need cloning.
Regards,
CVH