Apprentice API and Un-Enabled Parts

SteveLainson6531
Contributor

Apprentice API and Un-Enabled Parts

SteveLainson6531
Contributor
Contributor

Hello,

I'm looping through occurrences and wishing to exclude those that are not enabled from a List but although the parts/assemblies are not enabled in my .IAM I'm looking at the API doesn't seem to recognise this.

oOcc.Excluded does trigger a response but I cant figure out if this means suppressed, visible or enabled or some hierarchical  combination of these?

 

The code below does not trigger any response but oOcc.Excluded does - Looking at my model I think may flags visible OR not Enabled.

 

Can anyone explain for me please?

 

 

Dim oOcc As ComponentOccurrence        
For Each oOcc In Occurrences
            If oOcc.Enabled = False Then
                Debug.Print(oOcc._DisplayName & " is not ENABLED.")
            End if
Next

 

0 Likes
Reply
318 Views
2 Replies
Replies (2)

A.Acheson
Mentor
Mentor

Excluded according to the API help refers to iAssemblies so I would guess this is not what your after. 

 

https://help.autodesk.com/view/INVNTOR/2021/ENU/?guid=GUID-28F8CC6E-F7EF-4DCC-AB95-06522C2DEF2F

 

Enabled and visibility:

https://help.autodesk.com/view/INVNTOR/2021/ENU/?guid=GUID-19E2C95A-1AF1-466D-B97C-811388A31F15

 

 

Most occurrence in there normal state is set to be enabled as true. Maybe you want to check if visible or suppressed? 

 

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

SteveLainson6531
Contributor
Contributor

Thanks for your help, after some digging I found the problem - its the LoD. By default Apprentice seems load the Master LoD and hence why it was not reporting any suppressed/non enabled etc. parts so I had to OpenWithOptions. This link solved my problem https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/open-document-in-last-saved-level-of-de...  - the useful bit of code is below.

Dim strFullFileName As String
    strFullFileName = "C:\temp\Assembly1.iam"
       
    ' Set a reference to the FileManager object.
    Dim oFileManager As FileManager
    Set oFileManager = oApprentice.FileManager
    
    ' Get the name of the last active Level of Detail (LOD) Representation.
    Dim strLastActiveLOD As String
    strLastActiveLOD = oFileManager.GetLastActiveLevelOfDetailRepresentation(strFullFileName)
    
    ' Use the full file name and LOD name to get the full document name.
    Dim strFullDocumentName As String
    strFullDocumentName = oFileManager.GetFullDocumentName(strFullFileName, strLastActiveLOD)
    
     ' Create a new NameValueMap object
    Dim oDocOpenOptions As NameValueMap
    Set oDocOpenOptions = oApprentice.TransientObjects.CreateNameValueMap

    ' Open the document.
    Dim oDoc As ApprenticeServerDocument
    Set oDoc = oApprentice.OpenWithOptions(strFullDocumentName, oDocOpenOptions)

 

0 Likes