Question: using the ECMA scripting interface, how can I add cloned Objects to a document, without overriding the original ones?
Description: I am writing a script that recursively explodes all RBlockReferenceEntities in a document, i.e. retrieves all the REntities inside a block, and adds them to the document via a transaction of the kind:
Code: Select all
// Add all the new
var expAddOp = new RAddObjectsOperation();
for (var i = 0; i < debris.length; i++) {
expAddOp.addObject(debris[i], false);
}
var transaction = expAddOp.apply(doc);
I have tried cloning the underlying block entities, but the clones have the same id as the original. I have also tried to use `RObject.setId`, but it is a protected method.
So, how can I clone an entity with a new unique Id not present in the drawing? Or how can I create an RAddObjectOperation that looks at the ids, and generate new ones if duplicate?
Thanks!