Attach dxf to ipt via "Insert Object" and "Create from File" using iLogic

Attach dxf to ipt via "Insert Object" and "Create from File" using iLogic

Anonymous
Not applicable
884 Views
2 Replies
Message 1 of 3

Attach dxf to ipt via "Insert Object" and "Create from File" using iLogic

Anonymous
Not applicable

We've got 1000+ sheet metals part files we'd like to attach it's own dxf to. Manually we do this by going to Manage -> Insert Object -> Create from file -> browse to file -> check "Link" checkbox -> OK. Then after we move it to Vault, when we release the ipt, it'll automatically also release the dxf. 

 

For the first 1000ish parts that have been migrated, this step wasn't followed. Is there a way I can do this with an iLogic rule from a large assembly where I have all the ipt's that don't have a dxf attached?

 

Note: ipt and dxf always have the same file name (except for the file extension of course)

0 Likes
Accepted solutions (1)
885 Views
2 Replies
Replies (2)
Message 2 of 3

JelteDeJong
Mentor
Mentor
Accepted solution

I assumed that the ipt and dxf files are also in the same directory. Try this iLogic rule.

Dim doc As AssemblyDocument = ThisDoc.Document
Dim nl = System.Environment.NewLine
Dim notFOundList = "The following files where not found:" & nl
For Each refDoc As Document In doc.ReferencedDocuments
    If refDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
        Dim fileName As String = refDoc.FullFileName
        fileName = fileName.Replace(".ipt", ".dxf")
        If (IO.File.Exists(fileName)) Then
            refDoc.ReferencedOLEFileDescriptors.Add(fileName, OLEDocumentTypeEnum.kOLEDocumentLinkObject)
        Else
            notFOundList = notFOundList & fileName & nl
        End If
    End If
Next
MsgBox(notFOundList)

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 3

Anonymous
Not applicable

Thank you JelteDeJong! It worked perfectly right away. You've saved us so many hours. All the best!

0 Likes