我正在尝试在Revit中导出所选对象的图像。单击按钮时,将运行以下方法:
public void createPreviewImage(ExternalCommandData commandData)
{
TaskDialog.Show("Notification", "Starting creation of preview image.");
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;
var opt = new ImageExportOptions
{
ZoomType = ZoomFitType.FitToPage,
PixelSize = 128,
FilePath = "C:/Users/Dan/Desktop",
FitDirection = FitDirectionType.Horizontal,
HLRandWFViewsFileType = ImageFileType.JPEGLossless,
ImageResolution = ImageResolution.DPI_600,
};
doc.ExportImage(opt);
TaskDialog.Show("Notification", "Preview image created!");
}
虽然IDE在编译时不会出现任何错误,并且在运行该方法时会显示任务对话框,但不会在桌面上创建导出的图像。代码中的某个问题或图像导出的工作方式是否有所不同?
您的代码是正确的,但FilePath不完整。
FilePath = "C:/Users/Dan/Desktop/somefilename.jpg"