问题描述
我刚刚开发了一种方法,可以让我创建地板。 作为 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);
points[1] = new XYZ(0,10,0);
points[2] = new XYZ(10,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;
}
}
}
解决方法
您需要在创建楼层后提交您的交易。
,谢谢你提出这个问题,我第一次遇到它时很挣扎。
您需要添加
transaction.Commit();
在return Result.Succeeded;
之前