Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Resolve file by API

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
1714 Views, 3 Replies

Resolve file by API

Hi,

 

I'm using Inventor 2017 and sometimes some files are not found.

 

Is it possible to solve the file through the API instead of using the Inventor command?

 

My idea is to create an API to automatically solve lost reference problems without the need of users intervention.

 

Resolve File.png

 

Thanks.

 

 

3 REPLIES 3
Message 2 of 4
sajith_subramanian
in reply to: Anonymous

Hi marcelo.zattera,

 

Please see below a piece of VBA code that does something similar. There could be better ways to achieve this, but hopefully this should help get you started.

 

Sub main()
    Dim assemdoc As AssemblyDocument
    Set assemdoc = ThisApplication.ActiveDocument
    
    Dim oCCs As ComponentOccurrences
    Dim occ As ComponentOccurrence
    
    Dim Path As String
    Dim Filename As String
    Dim FullFileName As String
    Dim Resolvedfile As String
    
    Set oCCs = assemdoc.ComponentDefinition.Occurrences
    
    Path = "C:\Temp\"   'The path which contains the unresolved file
    
    For Each occ In oCCs
      ' check for missing reference.
        If occ.ReferencedDocumentDescriptor.ReferenceMissing = True Then ' This will return true for unresolved and suppressed.
         
            FullFileName = occ.ReferencedDocumentDescriptor.FullDocumentName 'Get the full document name
           
            Filename = Right$(FullFileName, Len(FullFileName) - InStrRev(FullFileName, "\"))  ' Extract the filename from the full filename.
             
            Resolvedfile = ThisApplication.DesignProjectManager.ResolveFile(Path, Filename)  'Resolve file. Full file name is returned. Null will be returned if cannot be resolved.
              
            Call occ.Replace(Resolvedfile, False)  ' replace unresolved occurrence with the resolvedfile
            
        End If
      
    Next

End Sub

 

Do let me know if it works for you.

 

Regards,

Sajith


Sajith Subramanian
Autodesk Developer Network
Message 3 of 4
Anonymous
in reply to: sajith_subramanian

Thanks Sajith.

 

The example you sent helped a lot.

Message 4 of 4
varad.keshatwar
in reply to: Anonymous

@sajith_subramanian do you have any idea, how this can be done using
Apprentice Server

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report