Is it possible in iLogic to select a file in a dialog box or a browser ?
I need to replace the 3d model on a drawing. I have to ask the user to select the new file to use. How can I select the file using a dialog box or a browser ?
The best should be a combobox with the list of opened files, and a button to browse on the disk, like when you create a view.
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Hi TONELLAL,
You can use something along these lines:
'present a File Selection dialog Dim 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 MessageBox.Show("You selected: " & selectedfile , "iLogic")
But I'm not sure about the combo box and buttons you mentioned.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Hi,
is there a way to then save the selected file's name and path and remove the extension (iam)? I would like to write a section of code to save the idw with the selected files name
You could take Curtis' code and do something like:
SyntaxEditor Code Snippet
'present a File Selection dialog Dim oDoc As Document = ThisDoc.Document Dim DrawingFileName As String Dim 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 DrawingFileName = Left(selectedfile, ((Len(selectedfile)-3))) & "idw" oDoc.SaveAs(DrawingFileName, False)
I'm sure there is an easier way to change the file extension; selectedfile.ExtensionTo(.idw) or something like that but this code should work as it is for you
Can't find what you're looking for? Ask the community or share your knowledge.