AllLeafOccurrences and View Representation

AllLeafOccurrences and View Representation

SteveK88
Advocate Advocate
1,005 Views
6 Replies
Message 1 of 7

AllLeafOccurrences and View Representation

SteveK88
Advocate
Advocate

In Inv 2023 iLogic, I am using AllLeafOccurrences to cycle thru a large assemblies to turn off the visibility of specific parts by iProp value.  This I then create a filtered Parts List by View Representation.

 

The problem is with subassemblies that have a BOM Structure other than Phantom still show in the filtered Parts List.

 

AllLeafOccurrences only search thru parts (ipt).  Is there a better method that will search for Parts & Assemblies?

 

Do I need to cycle thru twice once for parts and again for Assemblies by BOM Structure.  The file could have 10K occurrences!

Parts List Filtered.jpg

0 Likes
Accepted solutions (1)
1,006 Views
6 Replies
Replies (6)
Message 2 of 7

A.Acheson
Mentor
Mentor

You can use AllReferenceOccurrences and a recursion function. see syntax reference here

 

Syntax

ComponentOccurrences.AllReferencedOccurrences( Object As Object ) As ComponentOccurrencesEnumerator

 

And also methods to work with assemblies and occurrences here.  Can you post the relevant  code your using ?

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 7

SteveK88
Advocate
Advocate

Thanks for the info.  I will try this.

 

My code is attached.  This version searched by Name as it is faster that iProp but I may need both.

It is setup with Case statements so users can 'hard code' the search variables.

 

0 Likes
Message 4 of 7

SteveK88
Advocate
Advocate

Using AllReferencedDocuments recognizes the document (iam & ipt) not the occurrence.

 

I can turn off visibility of occurrences but not of a document.

I would need to cycle thru all occurrences of the found document (iam & ipt) and turn off the visibility.

Kind of back to the original issue.

 

Am I missing something?

 

0 Likes
Message 5 of 7

A.Acheson
Mentor
Mentor
Accepted solution

I see the behavior now. The assemblies visibility was remaining on even thou the parts were switched off. 

Change this line

 For Each oOcc In oOccs.AllLeafOccurrences

to 

For Each oOcc In oOccs.AllReferencedOccurrences(oDef)

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 6 of 7

SteveK88
Advocate
Advocate

Thank you. But that will now turn off visibility of the parent assembly that I do not want since all children are then non-visible.

 

I'll need to add a line to identify the assembly BOM Structure.  If BOM Structure is Phantom, not to turn off visibility.

or

It might be better to run thru turnoff all assemblies then run again to turn ON the parts I want on.

 

0 Likes
Message 7 of 7

SteveK88
Advocate
Advocate

It is working, I had to stitch this in,

 

If oOcc.BOMStructure <> 51971 Or oOcc.DefinitionDocumentType = kPartDocumentObject  Then 'Phantom BOM Structure AND not a Part