iLogic for copy Unresolved part in Assembly from another Project

iLogic for copy Unresolved part in Assembly from another Project

ballnr
Advocate Advocate
322 Views
4 Replies
Message 1 of 5

iLogic for copy Unresolved part in Assembly from another Project

ballnr
Advocate
Advocate

In my case, I have project A (in A folder) & B (in B folder).

Inside project A, I have "Assy.iam", "1.ipt" and "2.ipt".

When I copy only "Assy.iam" from project A and put in project B after that I active project B and open "Assy.iam". You will see Unresolved file same this picture

01.jpg

I get some iLogic to serch path of Unresolved file from this forum. (you can see it in "Assy.iam" inside project B)

Can every one help me to add some iLogic to copy Unresolved file from project A to project B, please?

0 Likes
323 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor

Hi @ballnr.  This sounds like a fairly common issue that has been discussed in the forums several times before.  You basically want to be able to copy an assembly, and all of its parts/sub-assemblies, from its current location to another location, and have the resulting assembly and all of its parts/sub-assemblies be completely independent from the originals, and to it all by code, right?  It can be a long and complex process to try to do completely by code.  Here are a couple of those other forum post links you can review, if you haven't already.

https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/save-and-replace-parts-in-an-assembly-u...

https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/ilogic-copy-assembly-rename-and-place-i... 

https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/save-and-replace-every-sub-assembly-and...

 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

ballnr
Advocate
Advocate

Thank you for your reply. But for my case, project A this is a folder which I get all everything from vault (That is a very big file). And project A is on oldserver that is vary slow. I cannot browser to A project and open it with Inventor. That is the reason why I need to do like that.

0 Likes
Message 4 of 5

ballnr
Advocate
Advocate
Sub main()
        Dim oFile As Inventor.File
         oFile = ThisApplication.ActiveDocument.File
        
        Dim oDoc As AssemblyDocument
         oDoc = ThisApplication.ActiveDocument
        oDoc.Save
        
        Dim oDocDef As AssemblyComponentDefinition
         oDocDef = oDoc.ComponentDefinition
        
        Call ProcessReferences(oFile, oDoc, oDocDef)

End Sub
Private Sub ProcessReferences(ByVal oFile As Inventor.File, oDoc As AssemblyDocument, oDocDef As ComponentDefinition)

        Dim oFileDescriptor As FileDescriptor
        For Each oFileDescriptor In oFile.ReferencedFileDescriptors
            If Not oFileDescriptor.ReferenceMissing Then
                If Not oFileDescriptor.ReferencedFileType = FileTypeEnum.kForeignFileType Then
                    Call ProcessReferences(oFileDescriptor.ReferencedFile, oDoc, oDocDef)
                End If
            Else
            Dim oComp As ComponentOccurrence
            For Each oComp In oDocDef.Occurrences
            If oComp.ReferencedDocumentDescriptor.ReferencedFileDescriptor.FullFileName = oFileDescriptor.FullFileName Then			
            'MsgBox(oFileDescriptor.FullFileName & vbCrLf & oFileDescriptor.RelativeFileName)
            'oComp.Delete
			Dim modelFileName As String = IO.Path.GetFileName(oFileDescriptor.FullFileName)
			Dim source As String = oFileDescriptor.FullFileName & vbCrLf & oFileDescriptor.RelativeFileName
            Dim destination As String = ThisDoc.Path & "\" & modelFileName'change as needed
			'MsgBox(source)
			'MsgBox(destination)
			Dim fso = ThisApplication.FileManager.FileSystemObject
			fso.copyFile(source, destination, True) 'True to overwrite

            End If
            Next oComp
            End If
                       
        Next
End Sub

I try to modify it. But I have some error. Please suggest.
02.jpg
0 Likes
Message 5 of 5

ballnr
Advocate
Advocate
Sub main()
        Dim oFile As Inventor.File
         oFile = ThisApplication.ActiveDocument.File
        
        Dim oDoc As AssemblyDocument
         oDoc = ThisApplication.ActiveDocument
        oDoc.Save
        
        Dim oDocDef As AssemblyComponentDefinition
         oDocDef = oDoc.ComponentDefinition
        
        Call ProcessReferences(oFile, oDoc, oDocDef)

End Sub
Private Sub ProcessReferences(ByVal oFile As Inventor.File, oDoc As AssemblyDocument, oDocDef As ComponentDefinition)

        Dim oFileDescriptor As FileDescriptor
        For Each oFileDescriptor In oFile.ReferencedFileDescriptors
            If Not oFileDescriptor.ReferenceMissing Then
                If Not oFileDescriptor.ReferencedFileType = FileTypeEnum.kForeignFileType Then
                    Call ProcessReferences(oFileDescriptor.ReferencedFile, oDoc, oDocDef)
                End If
            Else
            Dim oComp As ComponentOccurrence
            For Each oComp In oDocDef.Occurrences
            If oComp.ReferencedDocumentDescriptor.ReferencedFileDescriptor.FullFileName = oFileDescriptor.FullFileName Then			
            'MsgBox(oFileDescriptor.FullFileName & vbCrLf & oFileDescriptor.RelativeFileName)
            'oComp.Delete
			Dim modelFileName As String = IO.Path.GetFileName(oFileDescriptor.FullFileName)
			Dim source As String = oFileDescriptor.FullFileName
                        Dim destination As String = ThisDoc.Path & "\" & modelFileName
			Dim fso = ThisApplication.FileManager.FileSystemObject
			fso.copyFile(source, destination, True) 'True to overwrite

            End If
            Next oComp
            End If
                       
        Next
End Sub 

Now It possible to do. But when I have sub-assemly inside main-assembly I need to run many times.
Can some body help me to modify it when I have sub-assemly inside main-assembly, please?
0 Likes