【问题标题】:C# - Display a floor created with the Revit APIC# - 显示使用 Revit API 创建的楼板
【发布时间】:2021-06-01 05:13:27
【问题描述】:

我刚刚开发了一种可以创建地板的方法。 作为 Revit API 的新手,在我看来,我刚刚创建的地板存在,但在 Revit 上尚不可见。 所以我的问题如下:如何让这个地板在 Revit 中可见?

我可能错了,在这种情况下,如果你能向我解释问题,我会很高兴。

谢谢!

public Result CreateFloor(UIApplication uiapp)
        {
            UIDocument uiDoc = uiapp.ActiveUIDocument;
            Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
            Document doc = uiDoc.Document;

            using (Transaction transaction = new Transaction(doc))
            {

                if (transaction.Start("Create floor") == TransactionStatus.Started)
                {
                    XYZ[] points = new XYZ[3];
                    points[0] = new XYZ(0,0,0);
                    points[1] = new XYZ(0,10,0);
                    points[2] = new XYZ(10,0,0);

                    CurveArray curve = new CurveArray();

                    Line line1 = Line.CreateBound(points[0], points[1]);
                    Line line2 = Line.CreateBound(points[1],points[2]);
                    Line line3 = Line.CreateBound(points[2], points[0]);
                    curve.Append(line1);
                    curve.Append(line2);
                    curve.Append(line3);

                    Floor floor=doc.Create.NewFloor(curve, false);
                    return Result.Succeeded;
                }
                else
                {
                    transaction.RollBack();
                    return Result.Failed;
                }
            }
        }

【问题讨论】:

    标签: c# c#-4.0 c#-3.0 c#-2.0 revit-api


    【解决方案1】:

    您需要在创建楼层后提交交易。

    【讨论】:

      【解决方案2】:

      感谢您提出这个问题,我第一次遇到它时遇到了困难。

      你需要添加

      transaction.Commit();
      

      return Result.Succeeded;之前

      【讨论】:

        猜你喜欢
        • 2019-08-06
        • 2021-10-18
        • 2019-07-22
        • 1970-01-01
        • 2019-08-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-10-17
        相关资源
        最近更新 更多