Sample code:
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
try
{
var document = commandData.Application.ActiveUIDocument.Document;
Transaction transaction = new Transaction(document, "Create Floor");
transaction.Start();
var points = new List<XYZ>()
{
new XYZ(5.0, 0.0, 0.0),
new XYZ(0.0, 5.0, 0.0),
new XYZ(0.0, 0.0, 5.0)
};
var curves = new CurveArray();
curves.Insert(document.Application.Create.NewLine(points[0], points[1], true), 0);
curves.Insert(document.Application.Create.NewLine(points[1], points[2], true), 1);
curves.Insert(document.Application.Create.NewLine(points[2], points[0], true), 2);
var floorTypes = new FilteredElementCollector(document).OfClass(typeof(FloorType));
var floorType = floorTypes.ToList()[0] as FloorType;
var levels = new FilteredElementCollector(document).OfClass(typeof(Level));
var level = levels.ToList()[0] as Level;
var normal = new XYZ(1.0, 1.0, 1.0);
var floor = document.Create.NewFloor(curves, floorType, level, true, normal);
transaction.Commit();
}
catch
{
return Result.Failed;
}
return Result.Succeeded;
}
If I want to run this code an error message comes up:
"A first chance exception of type 'Autodesk.Revit.Exceptions.InvalidOperationException' occurred in RevitAPI.dll
Additional information: Could not construct a proper face with the input curves to create a floor correctly."
The NewFloor function is works well with horizontal lines and vertical normal vector. What is the role of the normal vector if the function is only works with horizontal lines? There is other NewFloor function without normal vector parameter ... why is the normal vector parameter there at the first version?
How can i create sloped floor?
(I use Revit 2013 API)
Regards
David Schmidt
Solved! Go to Solution.