Hi Andrew,
just another questions:
1. Am I right to assume that the Id of an REntity is fixed? That it does not change by modifying the entity ? And it stays the same after saving and restoring, even when the releasees of QCAD progress?
And, if I delete one entity, that its Id will never be reused?
2. I found that RObject carries a member ParentId. Is it already used in QCAD, and, if yes, for what purpose? If not, can I use it in my application to build up some Parent-Child-Relationship which stays intact in the cases mentioned above?
The reason for asking is that in my application I need to combine a number of Entities as belonging together (some kind of path over a couple of Entities). My Idea would be to store the ID of the first entity as ParentId to all successors. Would this be possible?
The alternative I know until know is to combine all Elements into a Block. However, this approach has a couple of disadvantages for the user, as manipullation of one of the elements is more complicated ....
Thanks in advance!
Ulrich
REntity::Id and RObject::ParentId
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Re: REntity::Id and RObject::ParentId
That's correct.mink wrote:That it does not change by modifying the entity ?
No, IDs are not persistent. If you need to refer to entities in a persistent way, you'd have to use the entity handle instead. That stays the same for the lifetime of the entity, even if stored / reloaded.And it stays the same after saving and restoring, even when the releasees of QCAD progress?
This is true for IDs and handles.And, if I delete one entity, that its Id will never be reused?
The parent ID is used for logical child / parent relationships that also exist on the file format level. This is currently only used to link block attributes (which live as independent entities at the same level as their block references) to their block references.2. I found that RObject carries a member ParentId. Is it already used in QCAD, and, if yes, for what purpose? If not, can I use it in my application to build up some Parent-Child-Relationship which stays intact in the cases mentioned above?
I would not recommend that, no.The reason for asking is that in my application I need to combine a number of Entities as belonging together (some kind of path over a couple of Entities). My Idea would be to store the ID of the first entity as ParentId to all successors. Would this be possible?
The first question with such constructs should always be how to store them in DXF/DWG. If a structure is not supported by the DXF/DWG format, it can probably be represented in QCAD but not stored.
Yes. Teaching the concept of blocks to users is not trivial.The alternative I know until know is to combine all Elements into a Block. However, this approach has a couple of disadvantages for the user, as manipullation of one of the elements is more complicated ....
Re: REntity::Id and RObject::ParentId
Hi Ulrich,mink wrote: 2. I found that RObject carries a member ParentId. Is it already used in QCAD, and, if yes, for what purpose? If not, can I use it in my application to build up some Parent-Child-Relationship which stays intact in the cases mentioned above?
The reason for asking is that in my application I need to combine a number of Entities as belonging together (some kind of path over a couple of Entities). My Idea would be to store the ID of the first entity as ParentId to all successors. Would this be possible?
I had a similar issue in the project I am currently working on, I overcame it by using custom properties.
Depending on your needs (mine were quite simplistic), you could store the parent id in each child or vice-versa and store the child id's in the parent but this would mean more custom properties in the parent.
This worked out okay for me because a parent only ever has one child but I can see this might be an issue if you have hundreds of children.
It is not ideal but might be workable depending on your needs.
Andrew.
Re: REntity::Id and RObject::ParentId
Hi Andrew,
thanks for the answers. As the IDs are not persistent, I will try to store the objects handles as custom properties.
Looks like a workable approach!
Regards and thanks!
Ulrich
thanks for the answers. As the IDs are not persistent, I will try to store the objects handles as custom properties.
Looks like a workable approach!
Regards and thanks!
Ulrich