Я учусь создавать надстройки для revit и пытаюсь создать, используя пример ниже. Итак, я получил код из revit api.chm, вопрос в том, как я могу использовать его как Revit Addin? Большое спасибо.
namespace somenamespace
{
[TransactionAttribute(TransactionMode.Manual)]
public class CreateFloor : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
//Get UIDocument
UIDocument uidoc = commandData.Application.ActiveUIDocument;
//Get Document
Autodesk.Revit.DB.Document doc = uidoc.Document;
Floor CreateFloor(UIApplication application, Level level)
{
// Get the Revit document
Autodesk.Revit.DB.Document document = application.ActiveUIDocument.Document;
// Get the application creation object
Autodesk.Revit.Creation.Application appCreation = application.Application.Create;
// Get a floor type for floor creation
FilteredElementCollector collector = new FilteredElementCollector(document);
collector.OfClass(typeof(FloorType));
FloorType floorType = collector.FirstElement() as FloorType;
// Build a floor profile for the floor creation
XYZ first = new XYZ(0, 0, 0);
XYZ second = new XYZ(20, 0, 0);
XYZ third = new XYZ(20, 15, 0);
XYZ fourth = new XYZ(0, 15, 0);
CurveArray profile = new CurveArray();
profile.Append(Line.CreateBound(first, second));
profile.Append(Line.CreateBound(second, third));
profile.Append(Line.CreateBound(third, fourth));
profile.Append(Line.CreateBound(fourth, first));
// The normal vector (0,0,1) that must be perpendicular to the profile.
XYZ normal = XYZ.BasisZ;
return document.Create.NewFloor(profile, floorType, level, true, normal);
}
return Result.Succeeded;
}
}