Cancel
Showing results for 
Search instead for 
Did you mean: 

Lost reference

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

I noticed when a face or edge has changed due to some operation like cut or split etc. the reference is lost and the only way to get the face back for more operations is to pre-store its ID and query it back using the Faces collection.

 

Has anyone faced a similar problem. How did you solve it ?

 

I thought of storing attributes on the face to retrieve it back later when the reference is lost but ID seems to be reliable and working for now.

 

I wrote TopoTools just to assist with this task. If there is a proper solution, I am still willing to to adopt it instead of the clumsy and time consuming TopoTools + Spy combination.

 

Thanks,

Tushar

 

12 REPLIES

Re: Lost reference

Phenom
Phenom
I had a similar problem and the solutions seems to be to use the "ReferenceKey" of the face\edge etc. instead of the ID. For what I have learned the "ReferenceKey" is unique and doesn't change in subsequent events.

Unfortunately the use of the "ReferenceKey" is not that easy (for my skills) as the ID.
I have problem to store them to be usable to retrieve the referenced object later.

I did give up after some time spend trying it, programming is not my primary work.

I would be very happy if there were an already written code to store ReferenceKeys and to retrieve Objects based on that stored ReferenceKeys.

A challenge for you Tushar ? :-)

Re: Lost reference

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

Thank you so much Francesco for the much needed hint.

I worked it out the following way:

 

		Dim bRefKey() As Byte = {}
		oFace.GetReferenceKey(bRefKey)
' Modify the face between here oDoc.BindKeyToObject(bRefKey, oFace)

 

Works like a charm !

 

~Tushar

Re: Lost reference

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Just to explain the differences between the Parasolid ID and the ReferenceKey:

 

* the Parasolid ID is unique during a session and may change when you later open the same document again, so this ID is NOT persistent

 

* if you need persistency between sessions, then you definitely need to use the ReferenceKeys, as they remain the same over multiple sessions and it is easy to retrieve the topology by using the BindKeyToObject() method on the Solid Edge document

Re: Lost reference

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

Thank you @MartinBernhard for the insight.

 

~Tushar

 

Re: Lost reference

Phenom
Phenom

Sorry to tag on to an old thread, but I'm trying to use the reference key instead of the item ID and I was a bit confused by a situation.

 

 

Why, when I use GetReferenceKey on a face, is it asking me for an array for the first argument when I have selected a single face? How do I use this properly and then also use BindToObject properly with the result?

-Dylan Gondyke

Re: Lost reference

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

Hi Dylan:

 

I'd still say the code snippet in my previous reply shows the complete usage.

 

First you would declare an empty array and pass it as a ByRef argument:

Dim bRefKey() As Byte = {}
oFace.GetReferenceKey(bRefKey)

I have seen Solid Edge fills some 40-42 bytes of data in the array which could be some kind of encrypted unique identifier key blah, blah for that face which is persistent though and can be used to identify it later even when the face is modified or between Solid Edge sessions, where the ID property as @MartinBernhard mentioned may not be of mush use.

   

To retrieve the face later, use:

oDoc.BindKeyToObject(bRefKey, oFace)

In the above line, pass back the bRefKey as an argument which was stored earlier in the program to get back the face in oFace which is a ByRef argument.

   

Between these two calls, the face could be modified. In my use case I trimmed the face and could still get it back successfully.

  

Let me know if are facing any specific issue using this.

 

Tushar

Re: Lost reference

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

The byte array for the reference key can be much longer than the 40-42 bytes as it encodes the roadmap from the model to the final face. If there are more features involved in the creation of the face, the array is much longer!

 

EDIT: Especially, if you modify the face later, like trimming, the reference key will be bound to the face at a specific state in the feature tree. This is as if you would have rolled your tree back to the specific feature.

In your trim test, the topology probably did not change, only geometry, so that the face after the trimming would be still the same face, but with a different surface attached.

Re: Lost reference

Phenom
Phenom

Thank you Martin, Tushar. I was confused by the differences in GetReferenceKey methods between edges/other objects and faces. Tushar, you were correct. As always Martin, your insight here serves also to show how much there is to learn.

-Dylan Gondyke

Re: Lost reference

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

@MartinBernhardwrote:

The byte array for the reference key can be much longer than the 40-42 bytes as it encodes the roadmap from the model to the final face. If there are more features involved in the creation of the face, the array is much longer!

 

EDIT: Especially, if you modify the face later, like trimming, the reference key will be bound to the face at a specific state in the feature tree. This is as if you would have rolled your tree back to the specific feature.

In your trim test, the topology probably did not change, only geometry, so that the face after the trimming would be still the same face, but with a different surface attached.


@MartinBernhard

I have a serious question - have you gathered this deep information from general reading, or were you really a part of the team that planned and laid the architecture of the Solid Edge API or is there is a specific place in the documentation or any GTAC bulletin or hidden place where you gain such understanding and knowledge, or is it largely by exploring, experimenting and investigating the various API functions of Solid Edge.

   

Should not bother me as long as you are sharing it generously but this comes to mind in awe and admiration of the depth and breadth of the knowledge you possess.

   

Best regards,

Tushar