sramp wrote:For this reason I have decide to set a custom property with a unique key in the entities that I need to retrieve.
Yes, this should work fine.
sramp wrote:Please I would like to know which are the best strategies to find them after a save operation.
Iterate through all entities and find the ones with the custom property set to the appropriate value / ID. This should be reasonably fast.
sramp wrote:Further I need to know if also the layer id can change after modifications or save operation. I mean the id I get from entity.getLayerId.
Yes, all object ID's (entity IDs, layer IDs, block IDs, ...) are not persistent between saves.
sramp wrote:I suppose that if I know the layer where is located the entity I'm looking for my search could be faster. Am I correct ?
No. Entities are not in a any way ordered by layer. The layer is just an attribute.
Some optimizations exist for looking up entities by block.
sramp wrote:For this reason I would like to incorporate the layer id in my unique key.
This would be difficult to maintain. Imagine the user changes the layer an entity is on. The unique ID stored as custom property would have to be adjusted at that point.
Another thing to keep in mind is that entities can be copied. If a line entity with a custom property "MyID" set to 7 is copied, the copy will also have a custom property "MyID" which is also set to 7. I.e. the ID is no longer unique.