[英]C# - Display a floor created with the Revit API
I have just developed a method that allows me to create a floor.我刚刚开发了一种方法,可以让我创建一个地板。 Being new to the Revit API, it seems to me that the floor I just created exists but is not yet visible on Revit.
作为 Revit API 的新手,在我看来,我刚刚创建的地板存在,但在 Revit 上尚不可见。 So my question is the following: How do I make this floor visible in Revit?
所以我的问题如下:如何使这个地板在 Revit 中可见?
I might be wrong, in which case I would be happy if you could explain the problem to me.我可能是错的,在这种情况下,如果你能向我解释这个问题,我会很高兴。
Thank you!谢谢!
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;
}
}
}
You need to Commit your transaction after creating the Floor.您需要在创建楼层后提交您的交易。
Thank you for raising that question, I struggled the first time I encountered it.感谢您提出这个问题,我第一次遇到它时很挣扎。
You need to add您需要添加
transaction.Commit();
before return Result.Succeeded;
在
return Result.Succeeded;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.