I am trying to create a logic rule to replace the model reference in a idw file and then saveas using the new file reference name. I am able to do this for individual files or components within an assembly file.
However what I would like is to check through all files of a certain type (for example ipt with filenames beginning "SSUA" ) in a specific folder.
The following code from Curtis Waguespack works well for individual selected files but I would like to take it a stage further with the above parameters.
Any help would be most appreciated.?
Dim oDoc as Document oDoc = ThisDoc.Document Dim oRefFile As FileDescriptor Dim oOrigRefName As Object For Each oRefFile In oDoc.file.ReferencedFileDescriptors 'get the full file path to the original internal referencesoOrigRefName = oRefFile.FullFileName 'present a File Selection dialogDim oFileDlg As inventor.FileDialog = Nothing InventorVb.Application.CreateFileDialog(oFileDlg) oFileDlg.InitialDirectory = oOrigRefName oFileDlg.CancelError = True On Error Resume Next oFileDlg.ShowOpen() If Err.Number <> 0 Then Return ElseIf oFileDlg.FileName <> "" Then selectedfile = oFileDlg.FileName End If 'replace the referenceoRefFile.ReplaceReference (selectedfile) InventorVb.DocumentUpdate() oOrigRefName = "" Next iLogicVb.UpdateWhenDone = True Dim strNewRefName As String = Mid(selectedfile, 1, Len(selectedfile)- 4) & ".idw" 'Save copy as one new idw using the member nameThisDoc.Document.SaveAs(strNewRefName , True)
Hi,
Your question isn't directly related to the Inventor API, iterating through files in folders/performing search is more of the domain of general OS programming. We are trying to focus our support to Autodesk API specific questions here, but maybe a third party developer will be able to answer you.
In the meantime you should be able to find this kind of solution by looking VBA/VB6.0 forums through the web.
Sorry for not being more helpful.
Regards,
Philippe.
You can access the ReferencedFiles and ReferencedFileDescriptors for a document, however if you want to perform searches based on a specific filename or pattern in a specifc directory, you would have to rely on the functionalities provided by the operating system and the programming language/framework you are using.
Regards,
Philippe.