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.
How do I make this floor visible in Revit?
I might be wrong, in which case I would be happy if you could explain the problem to me.
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;
}
}
}