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: 

ILogic : browse to select a file

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
TONELLAL
4546 Views, 5 Replies

ILogic : browse to select a file

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.

5 REPLIES 5
Message 2 of 6

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

Message 3 of 6

Curtis,

Found this post. Exactly what I needed. Awesome. Thanks!!

Message 4 of 6
pontuti11
in reply to: FireBallFab

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

Message 5 of 6
DRLTKSE
in reply to: pontuti11

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 

Message 6 of 6
i.pous
in reply to: Curtis_Waguespack

is posible to select a folder?how?

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

Post to forums  

Autodesk Design & Make Report