Revit二次开发--保存项目文件当前视图

该文是学习了https://blog.csdn.net/The_Eyes/article/details/78105342博主的博文,对ImageExportOptions类及ImageView类学习后,做的测试,记录下来

	 public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
    {
        Document doc = commandData.Application.ActiveUIDocument.Document;
        using (Transaction trans = new Transaction(doc))
        {
            trans.Start("Export ImageView");
            ImageExportOptions options = new ImageExportOptions();
            options.ExportRange = ExportRange.CurrentView;
            options.FitDirection = FitDirectionType.Horizontal;
            options.ImageResolution = ImageResolution.DPI_72;
            options.PixelSize = 255;
            options.HLRandWFViewsFileType = ImageFileType.PNG;
            options.ZoomType = ZoomFitType.Zoom;
            options.Zoom = 10;

            options.FilePath = @"F:\test.png";
            doc.ExportImage(options);
            trans.Commit();
        }
        TaskDialog.Show("Information","保存完毕");
        return Result.Succeeded;
    }

本来想通过此种方法,保存族文档中的视图,但是此方法好像不能保存族文件视图

二、导出多个视图:

	 private void ExportSetOfViews(Document doc)
    {
        FilteredElementCollector collector = new FilteredElementCollector(doc);
        IList<Element> views = collector.OfClass(typeof(View)).OfCategory(BuiltInCategory.OST_Views).ToElements();
        IList<ElementId> viewExport = new List<ElementId>();
        foreach (Element ele in views)
        {
            View view = ele as View;
            if (view == null || view.IsTemplate)
                continue;
            viewExport.Add(view.Id);
        }

        using (Transaction trans = new Transaction(doc))
        {
            trans.Start("Export set of views");
            ImageExportOptions options = new ImageExportOptions
            {
                ZoomType = ZoomFitType.FitToPage,
                PixelSize = 255,
                FilePath = @"F:\Views\",
                FitDirection = FitDirectionType.Horizontal,
                HLRandWFViewsFileType = ImageFileType.PNG,
                ImageResolution = ImageResolution.DPI_72,
                ExportRange = ExportRange.SetOfViews
            };
            options.SetViewsAndSheets(viewExport);
            doc.ExportImage(options);
            trans.Commit();
        }
    }
  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值