REntity::Id and RObject::ParentId

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
mink
Active Member
Posts: 30
Joined: Mon Jan 19, 2015 7:20 pm

REntity::Id and RObject::ParentId

Post by mink » Thu Feb 19, 2015 4:05 pm

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

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: REntity::Id and RObject::ParentId

Post by andrew » Thu Feb 19, 2015 5:29 pm

mink wrote:That it does not change by modifying the entity ?
That's correct.
And it stays the same after saving and restoring, even when the releasees of QCAD progress?
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, if I delete one entity, that its Id will never be reused?
This is true for IDs and handles.
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 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.
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 would not recommend that, no.
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.
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 ....
Yes. Teaching the concept of blocks to users is not trivial.

Taygete
Full Member
Posts: 50
Joined: Wed May 14, 2014 8:53 am

Re: REntity::Id and RObject::ParentId

Post by Taygete » Fri Feb 20, 2015 9:18 am

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?
Hi Ulrich,

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.

mink
Active Member
Posts: 30
Joined: Mon Jan 19, 2015 7:20 pm

Re: REntity::Id and RObject::ParentId

Post by mink » Fri Feb 20, 2015 10:43 am

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

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”