首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >revit api创建工作表-文档-包含不推荐使用的"view3d

revit api创建工作表-文档-包含不推荐使用的"view3d
EN

Stack Overflow用户
提问于 2020-01-25 10:38:37
回答 1查看 460关注 0票数 1

我正在文档中尝试使用C#中的Revit API创建一个带有视图的工作表

here is the docs URL link。您可以在第一个C#块的底部找到代码。

我在view3D.Id下面有一个红色的弯曲

Viewport.Create(doc, viewSheet.Id, view3D.Id, new XYZ(location.U, location.V, 0));

我找不到它已被弃用,也找不到如何解决它。我有点搞不懂为什么它要抓取自己的elementID。另外,我刚进入revit-API。似乎Revit中的“视图”在API中称为“视口”。我需要阅读更多关于这方面的内容。

下面是整个代码块:

代码语言:javascript
复制
private void CreateSheetView(Autodesk.Revit.DB.Document document, View3D view3D)
{

    // Get an available title block from document
    FilteredElementCollector collector = new FilteredElementCollector(document);
    collector.OfClass(typeof(FamilySymbol));
    collector.OfCategory(BuiltInCategory.OST_TitleBlocks);

    FamilySymbol fs = collector.FirstElement() as FamilySymbol;
    if (fs != null)
    {
        using (Transaction t = new Transaction(document, "Create a new ViewSheet"))
        {
            t.Start();
            try
            {
                // Create a sheet view
                ViewSheet viewSheet = ViewSheet.Create(document, fs.Id);
                if (null == viewSheet)
                {
                    throw new Exception("Failed to create new ViewSheet.");
                }

                // Add passed in view onto the center of the sheet
                UV location = new UV((viewSheet.Outline.Max.U - viewSheet.Outline.Min.U) / 2,
                                     (viewSheet.Outline.Max.V - viewSheet.Outline.Min.V) / 2);

                //viewSheet.AddView(view3D, location);
                Viewport.Create(document, viewSheet.Id, view3D.Id, new XYZ(location.U, location.V, 0));
                ^ERROR HAPPENS IN LINE ABOVE AT view3D.Id


                // Print the sheet out
                if (viewSheet.CanBePrinted)
                {
                    TaskDialog taskDialog = new TaskDialog("Revit");
                    taskDialog.MainContent = "Print the sheet?";
                    TaskDialogCommonButtons buttons = TaskDialogCommonButtons.Yes | TaskDialogCommonButtons.No;
                    taskDialog.CommonButtons = buttons;
                    TaskDialogResult result = taskDialog.Show();

                    if (result == TaskDialogResult.Yes)
                    {
                        viewSheet.Print();
                    }
                }

                t.Commit();
            }
            catch
            {
                t.RollBack();
            }
        }
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-01-25 13:10:53

The Building Coder discussion of exact viewport positioning包含了一些对ViewSheet.CreateViewport.Create的工作样例调用。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59905898

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档