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: 

Replacing References with API

1 REPLY 1
Reply
Message 1 of 2
dbrblg
1579 Views, 1 Reply

Replacing References with API

Hi, 

 

I am trying to replace file references via the API.  So far I have this:

 

 

Const Assy = "\\xx\ConvertedData\Assy\"
Const Part = "\\xx\ConvertedData\Parts\"
Sub anothertest()
    Dim objDoc As Inventor.Document
    Dim objPar As Inventor.FileDescriptor
    Dim i As Long
    
    Set objDoc = ThisApplication.ActiveDocument
    
    For i = 1 To objDoc.File.ReferencedFileDescriptors.Count
        
        Set objPar = objDoc.File.ReferencedFileDescriptors.Item(i)
        Select Case objPar.ReferencedFileType
            Case kAssemblyFileType
                objPar.ReplaceReference Assy & GetFileName(objPar.ResolvedFullFileName)
            Case kPartFileType
                objPar.ReplaceReference Part & GetFileName(objPar.ResolvedFullFileName)
        End Select
        
    Next
    
    Set objDoc = Nothing
End Sub
The idea being a parasolid file is opened which creates the part / assy files within it.  This code will then run and replace each part and assy with one from a different location.
All I get when I run this is the error 'invalid procedure call or argument' at this position objPar.ReplaceReference Part & GetFileName(objPar.ResolvedFullFileName)
Can anyone point me on the right direction please?
Thanks

 

 

1 REPLY 1
Message 2 of 2
YuhanZhang
in reply to: dbrblg

Can you check that the objPar.ResolvedFullFileName returns a valid path? And also please make sure that the document being replaced share the same internal name with the replacement one.

 

See below remarks for ReplaceReference method in help:

The file being replaced and the replacement file must share ancestry (i.e. they must have the same InternalName). Documents have the same internal name if they are copied using 'Save Copy As' or a file explorer copy.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

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

Post to forums  

Autodesk Design & Make Report