OpenFileDialog with Preview

OpenFileDialog with Preview

lrsmns
Enthusiast Enthusiast
844 Views
8 Replies
Message 1 of 9

OpenFileDialog with Preview

lrsmns
Enthusiast
Enthusiast

Hi, i'm trying to implement a load family function in my plug-in. 
I was wondering if there is an existing OpenFileDialog from .NET or Revit API, which allows to have preview of the file?
Currently using it for Revit 2022

0 Likes
845 Views
8 Replies
Replies (8)
Message 2 of 9

lrsmns
Enthusiast
Enthusiast

Ah nvm, I found the ShowPreview property in FileOpenDialog 🙂

0 Likes
Message 3 of 9

lrsmns
Enthusiast
Enthusiast

Though my next question would be, would it be possible to set an initial directory with FileOpenDialog?

0 Likes
Message 4 of 9

Mohamed_Arshad
Advisor
Advisor

Hi @lrsmns 

 

    you can't able to set default location in FileOpenDialog, It will take recent file location as default location. Kindly check the below image and link for additional reference.

 

Reference Image

Mohamed_Arshad_0-1721124628438.png


URL: https://www.revitapidocs.com/2024/efe4f212-6400-eaec-9263-1665ba9c163f.htm#:~:text=The%20folder%20lo... 

 

Hope this will Helps 🙂

 


Mohamed Arshad K
Software Developer (CAD & BIM)

0 Likes
Message 5 of 9

lrsmns
Enthusiast
Enthusiast

yes unfortunately there is no option to do so then.. would have been nice to be able to set the initial directory. 
The OpenFileDialog from .NET has that option but with the old .NET framework it's not possible to show preview 😞

0 Likes
Message 6 of 9

Mohamed_Arshad
Advisor
Advisor

Hi @lrsmns 

 

    Post it in Ideas page, So one day Revit API will expose the option


Mohamed Arshad K
Software Developer (CAD & BIM)

0 Likes
Message 7 of 9

Moustafa_K
Advisor
Advisor

I think you can use the FileOpenDialog under Autodesk.Revit.UI

 

see this implementation:

Autodesk.Revit.UI.FileOpenDialog fd = new FileOpenDialog("rfa files|*.rfa");
fd.ShowPreview = true;
fd.Show();

Moustafa_K_0-1721790093116.png

 

Moustafa Khalil
Cropped-Sharp-Bim-500x125-Autodesk-1
0 Likes
Message 8 of 9

lrsmns
Enthusiast
Enthusiast

Well the only issue is that the provided FileOpenDialog from Revit doesnt provide a property to set Initial Directory

0 Likes
Message 9 of 9

lrsmns
Enthusiast
Enthusiast

Well the only issue is that the FileOpenDialog doesnt provide the property to set initial directory, which is also a requirement for my plug-in development