Orphan Attributes!

Orphan Attributes!

nnikbin
Collaborator Collaborator
587 Views
2 Replies
Message 1 of 3

Orphan Attributes!

nnikbin
Collaborator
Collaborator

Attributes will remain in design after deletion of their parents. In fact their parents will become nullptr (in C++). It can potentially cause exceptions if you iterate through all design attributes and try to work with their parents without nullptr checking.

 

Is it by design or a bug?

0 Likes
Accepted solutions (1)
588 Views
2 Replies
Replies (2)
Message 2 of 3

JeromeBriot
Mentor
Mentor
Accepted solution

Hello,

 

Taken from the documentation:

 

Something that might seem a little odd at first is that it is possible to get an attribute whose parent entity no longer exists. In that case, calling the parent property will return null. One example of where you can get an unattached attribute is in the case of B-Rep entities (faces, edges, and vertices of a model). When an attribute is created on a B-Rep entity it is never automatically deleted because the lifetime of that entity is unknown. For example, if you add an attribute to an edge and then the edge is filleted, that edge is consumed and no longer exists in the model and the parent property of the attribute will return null. However, it's possible that the edge can come back in the future; the fillet can be deleted or suppressed and then the parent property of the attribute will return the edge. Because attributes can exist without an owner, it's important to always check the return value of the parent property to verify that you did get back an entity.

 

Message 3 of 3

nnikbin
Collaborator
Collaborator

Thank you @JeromeBriot. It seems that I need to read the documentation more carefully!

0 Likes