after looking at scripts/Block/InsertBlock/InsertBlock.js I finally got a multi-insertion of blocks working. Now I'm wondering why
Code: Select all
var nextFreeId = document.getStorage().getMaxObjectId(); //<<<<<<<<< needed?
//...... something more here
//and then for each block to insert I do:
var blockRefId = nextFreeId++; //<<<<<<<<< needed?
var ids = document.queryBlockEntities(blockId);
for (var j = 0; j < ids.length; j++) {
var id = ids[j];
var e = document.queryEntity(id);
if (!isAttributeDefinitionEntity(e)) {
continue;
}
var att = new RAttributeEntity(document, new RAttributeData(e.getData(), blockRefId, e.getTag())); //<<<<<<< more parameters here than in code snippet below
blockRef.applyTransformationTo(att);
var tag = att.getTag();
if (!isNull(this.attributes[tag])) {
att.setText(this.attributes[tag]);
}
op.addObject(att);
}
Code: Select all
var ids = document.queryBlockEntities(blockId);
for (var j = 0; j < ids.length; j++) {
var id = ids[j];
var e = document.queryEntity(id);
if (!isAttributeDefinitionEntity(e)) {
continue;
}
var att = new RAttributeEntity(document, new RAttributeData(e.getData())); //<<<<<<<< call has other signature!!!
blockRef.applyTransformationTo(att);
var tag = att.getTag();
if (!isNull(this.attributes[tag])) {
att.setText(this.attributes[tag]);
}
op.addObject(att);
}
Thank you very much,
Stefan