I am seeing something odd when modifying entities.
If I modify a number of entities (each on a different layer) then call applyOperation it seems to be changing the entities layer to the documents currently selected layer. I thought I could overcome this by calling the entities setProperty(REntity::PropertyLayer...) method but this doesn't seem to make any difference to the outcome.
For instance, say I have three layers named Layer1, Layer2, and Layer3, each layer has a number of entities are assigned to it. I assumed modifying a custom property on each entity would not change the layer it is assigned too but after calling applyOperation this is what seems to be happening and all entities end up on the same layer. I then thought calling setProperty to set the Layer so it stays on the layer it is already assigned to but this doesn't work either. It is as if during the applyOperation method call the modified entities are being moved to the documents current layer rather than leaving them on their current layer.
Assuming the following code below (Note: CadRunItem and CadItem are my classes), which is slightly different to the scenario above to simplify the code:
RModifyObjectsOperation *modOp = new RModifyObjectsOperation(); // Sanity check if (modOp != NULL) { // The layer we want to move the entity into too. QString layerName = "Layer3"; // Loop through each item in the list and change the entities properties foreach (CadRunItem rItem, theRunItems.getItems()) { CadItem cItem = rItem.getItem(); QSharedPointer<REntity> entity; cItem.convertToEntity(docInterface, entity); if (entity.isNull()) { continue; } // Set Layer entity->setProperty(REntity::PropertyLayer, layerType); // Do other things with entity entity->setCustomProperty(...); .... modOp->addObject(entity); } // Apply the changes to the document docInterface->applyOperation(modOp); }In the code above I assumed the call to setProperty
Code: Select all
entity->setProperty(REntity::PropertyLayer, layerType);
I hope that makes sense please let me know if you want clarification.
Thanks,
Andrew.