Message 1 of 7
Create FileSaveDialog Box
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Seemingly simple question, but I had no luck searching around for the answer. I am trying to set the file path for an image I am exporting using C# in VisualStudio to create an .addin to use in Revit.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.DB.Architecture;
//We will not be committing any changes to the model, so read only for the transaction mode.
[Transaction(TransactionMode.ReadOnly)]
public class Main : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
//Get application and document objects
UIApplication uiapp = commandData.Application;
Document doc = uiapp.ActiveUIDocument.Document;
//
ImageExportOptions imgExportOpts = new ImageExportOptions();
{
imgExportOpts.ZoomType = ZoomFitType.FitToPage;
imgExportOpts.PixelSize = 500;
imgExportOpts.FilePath = "C:/Users/username/Documents/Test.TIFF";
imgExportOpts.FitDirection = FitDirectionType.Vertical;
imgExportOpts.HLRandWFViewsFileType = ImageFileType.TIFF;
imgExportOpts.ShadowViewsFileType = ImageFileType.TIFF;
imgExportOpts.ImageResolution = ImageResolution.DPI_72;
imgExportOpts.ShouldCreateWebSite = false;
};
doc.ExportImage(imgExportOpts);
//Returns success if programs runs well
return Result.Succeeded;
}
}
I am thinking of adding:
//Setting export path
string filePath;
public Return FileSaveDialog()
{
filePath = ...
return filePath
}
somewhere after I define doc as a type of class Document. As you can tell I am not really sure what I am doing here. I tried looking at other examples and the revitapi help document, to no avail. I would be really grateful for any assistance. I am not sure if I should be doing something more like:
FileSaveDialog fileSaveDialog = new FileSaveDialog(string);
{
Stuff inside here;
}