AllLeafOccurrences vs Wedment documents error

AllLeafOccurrences vs Wedment documents error

BenoitLarocque000
Enthusiast Enthusiast
455 Views
7 Replies
Message 1 of 8

AllLeafOccurrences vs Wedment documents error

BenoitLarocque000
Enthusiast
Enthusiast

I recently noticed that the AllLeafOccurrences collection is corrupted when you have Weldment sub assemblies in an assembly document.

the Weldment document (is a iam) but is present in the AllLeafOccurrences collection.

I also noticed that the occurrence that represents the Wedment document has an empty Name and a Proxy Type.

I used this property to exclude them from my processing but I think that they should not be present in this collection.

At first, I thought that their Bom Status (normally set to Inseparable) was responsible of the problem, but 

I tried to change their Bom status to normal and it doesn't seem to change anything.

 

Best regards,

 

Benoit Larocque

 

0 Likes
456 Views
7 Replies
Replies (7)
Message 2 of 8

jjstr8
Collaborator
Collaborator

What version of Inventor are you using?  I'm on 2019 and I checked an assembly that includes a weldment.  The parts of the weldment (including the weld bead) show up under <assemblydocument>.ComponentDefinition.Occurrences.AllLeafOccurrences as proxies with the weldment as their ContainingOccurrence.  The weldment does not show up in the collection.

0 Likes
Message 3 of 8

BenoitLarocque000
Enthusiast
Enthusiast

I'm using 2023.

The wedlment do not appear, but I consider that the presence of an occurrence that correspond to the Weldment assembly document in the "AllLeaf" collection is not suitable.

if you loop all items in a For Each, you expect that all occurrences will correspond to a part occurrence. 

it's like finding a banana in an orange bag  😉 . It's not a big deal, but I got a bit surprised when I noticed that.

 

Best regards,

 

Benoit Larocque

0 Likes
Message 4 of 8

jjstr8
Collaborator
Collaborator

It's probably always worked that way, where occurrences of any type of assembly show up in the collection.  It's probably best to check the OccurrencePath of any ComponentOccurrenceProxy items in the collection, and see if they belong to a weldment.

0 Likes
Message 5 of 8

BenoitLarocque000
Enthusiast
Enthusiast

Yes you are right, and that's what I do, (I verify if it's a proxy object to exclude it) but I keep thinking that if they named the collection "AllLeaf", then I should find Leaves only and no branch.

 

Best regards,

 

Benoit Larocque

0 Likes
Message 6 of 8

WCrihfield
Mentor
Mentor

Hi @BenoitLarocque000.  When loopling through ComponentOccurrence type objects, I use three main filters, fur just such occasions.

 

If oComp.Suppressed Then Exit Sub
If TypeOf oComp.Definition Is VirtualComponentDefinition Then Exit Sub
If TypeOf oComp.Definition Is WeldsComponentDefinition Then Exit Sub

 

And in that order, because you can not access the Definition of a component if it is suppressed.  You may want to replace 'Exit Sub' with 'Continue For' though, depending on where it is being used.  I often have a seperate Sub routine just for processing each component.  If you look at the online web page for the generic ComponentDefinition object, you will see that it is the basis for several other more specific types of ComponentDefinitions that are derived from that Type.  And you will find that the WeldmentComponentDefinition is derived from the AssemblyComponentDefinition.  And the SheetMetalComponentDefinition is derived from the PartComponentDefinition.  Even the FlatPattern, within the SheetMetalComponentDefinition is its own type of ComponentDefinition.  Similarly, the WeldsComponentDefinition, which is derived directly from the generic ComponentDefinition, can be found within a WeldmentComponentDefinition.  When there are welds present in the Weldment type assembly, you will need to use a filter like that to avoid processing that type of component.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 7 of 8

BenoitLarocque000
Enthusiast
Enthusiast

Hi @WCrihfield 

 

Thats what I do too.

 

Thanks for the reply

 

Best regards,

 

Benoit Larocque

0 Likes
Message 8 of 8

jjstr8
Collaborator
Collaborator

@BenoitLarocque000 :  By the definition of a "tree" structure, leaf nodes are nodes that have no children.  With that in mind, AllLeafOccurrences is indeed a collection of leaf nodes since no assemblies are included.  Assemblies would be a regular node while the structure itself would be called branches.  

0 Likes