Showing results for 
Search instead for 
Did you mean: 

ReferenceKey understanding?

Valued Contributor
Valued Contributor


I seek advice!

Given an asm, I recurse over Occurrences/SubOccurrences and build a table with a set of key-and-path-pairs on the form:

key1 ; top.asm

key2 ; top.asm/subasm.asm:1

key3 ; top.asm/subasm.asm:1/subsubasm:1

key4 ; top.asm/subasm.asm:1/subsubasm:1/leaf.par:1

and so on...

keyN-1 ; top.asm/subasm.asm:1/subsubasm:4

keyN ; top.asm/otherLeaf.par:1

The keys are the reference keys retrieved by GetReferenceKey() on the (Sub)Occurrences.

In top.asm, I then look at the Relations3d Collection.

Assume there is one mate done between leaf.par:1 and anotherLeaf.par:1.

I then have four relation objects (one for ground, three for the mated pair.)

I take one of the three and use GetElement1() to get the Reference Object.

On that Reference Object, I do ImmediateParent(). I get an Occurrence. Assume it has the name 'leaf.par:1'.

On that Occurrence, I do GetReferenceKey()


That last ReferenceKey I use to look into the table and expect to find


but instead I get


which means that the last ReferenceKey correspond to KeyN-1.

Now, THIS I find a but odd..

Any hints where I got lost? Is it me not understanding ReferenceKey or is it SE messing up?

I use SE v20.



Posted by: Maria Reinhammar
Post date: 3/12/2008 5:26:58 AM


RE: ReferenceKey understanding?

Valued Contributor
Valued Contributor



ReferenceKeys of Occurrences/SubOccurrences are only unique inside the AssemblyDocument where they belong to.

You can get the same RefKey for leaf.par (Occurrence) relative to subsubasm and for otherLeaf.par (Occurrence) relative to top.asm. ReferenceKeys of Occurrences are only unique inside the parent assembly.

Suboccurrences are always relative to the top level assembly and therefore are always unique inside the whole assembly structure.


If you have a ReferenceKey of a SubOccurrence you can always bind back to this SubOccurrence object by using the AssemblyDocument::BindKeyToObject() method. The AssemblyDocument should be the top level assembly here.


If you call the BindKeyToObject method with a ReferenceKey of an Occurrence, you can only get the correct Occurrence, if you call the method on its parent assembly.


My advice is to not mix up ReferenceKeys of Occurrences and SubOccurrences, but use only the ones for SubOccurrences.





Posted by: Martin Bernhard
Post date: 3/13/2008 3:08:46 AM

RE: ReferenceKey understanding?

Valued Contributor
Valued Contributor



Really appreciate that you took your time.

Yes, that helped. At least in the sense that you confirmed what I have come to suspect.

I will post another topic with my broader problem as I now have reached a certain level of desperation..

Thanks again!


Posted by: Maria Reinhammar
Post date: 3/17/2008 9:14:43 PM