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: 

Loop through specific file in folder

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
945 Views, 3 Replies

Loop through specific file in folder

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)

3 REPLIES 3
Message 2 of 4
philippe.leefsma
in reply to: Anonymous

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.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 4
Anonymous
in reply to: Anonymous

Philippe,

Thank you for your reply however I do not see how this is not related to Inventor when as shown by my question iLogic is being used to perform the change model reference and then save as routines.
On the very large models I am working with the computer slows to such a degree that is unworkable therefore the main model is split down into several smaller models.
To work with all the generated part and assembly files from the different models these are saved in the same folder. Hence rather than interrogating a number of different assembly files with iLogic/VBA/API etc. it would be easier to interrogate through a folder. I am rather surprised that you are saying there is nothing in Inventor that can looking at file occurrences in, for instance the current directory path.

Regards

Roy Linton
Project Design Manager

[cid:image003.jpg@01CD89DD.3FF215A0]
Springvale Business & Industrial Park
Bilston
Wolverhampton
WV14 0QL

*: 01902 491100
Mob: 07712 873505
DDI: 01902 499432
7: 01902 494080

*: roy.linton@berrysystems.co.uk
?: www.berrysystems.co.uk








Hill and Smith Ltd Registered in England No: 1270322

Registered office: Westhaven House, Arleston Way, Shirley, Solihull, West Midlands, B90 4LE

This message (and any associated files) is intended only for the
use of the individual or entity to which it is addressed and may
contain information that is confidential, subject to copyright or
constitutes a trade secret. If you are not the intended recipient
you are hereby notified that any dissemination, copying or
distribution of this message, or files associated with this message,
is strictly prohibited. If you have received this message in error,
please notify us immediately by replying to the message and deleting
it from your computer. Messages sent to and from us may be monitored.
Internet communications cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed, arrive
late or incomplete, or contain viruses. Therefore, we do not accept
responsibility for any errors or omissions that are present in this
message, or any attachment, that have arisen as a result of e-mail
transmission. If verification is required, please request a hard-copy
version. Any views or opinions presented are solely those of the author
and do not necessarily represent those of the company.
Message 4 of 4
philippe.leefsma
in reply to: Anonymous

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.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

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

Post to forums  

Autodesk Design & Make Report