using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.ApplicationServices;
namespace columnfamily
{
[Transaction(TransactionMode.Manual)]
public class Class1 : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;
UIApplication uiapp = commandData.Application;
Application app = uiapp.Application;
string path = @"C:\ProgramData\Autodesk\RVT 2018\Family Templates\Chinese\公制柱.rft";
Document faDoc = app.NewFamilyDocument(path);
Transaction trans = new Transaction(faDoc,"create column");
trans.Start();
CurveArray curveArray = new CurveArray();
curveArray.Append(Line.CreateBound(new XYZ(0, 0, 0), new XYZ(0, 100, 0)));
curveArray.Append(Line.CreateBound(new XYZ(0, 100, 0), new XYZ(100, 100, 0)));
curveArray.Append(Line.CreateBound(new XYZ(100, 100, 0), new XYZ(100, 0, 0)));
curveArray.Append(Line.CreateBound(new XYZ(100, 0, 0), new XYZ(0, 0, 0)));
CurveArrArray curveArrArray = new CurveArrArray();
curveArrArray.Append(curveArray);
SketchPlane sp = SketchPlane.Create(faDoc, Plane.CreateByNormalAndOrigin(new XYZ(0, 0, 1), XYZ.Zero));
Extrusion ex = faDoc.FamilyCreate.NewExtrusion(true, curveArrArray, sp, 4000 / 304.8);
faDoc.FamilyManager.NewType("new column");
trans.Commit();
faDoc.SaveAs(@"C:\Users\T5820\Desktop\龙");
faDoc.Close();
//Family fam = faDoc.LoadFamily(doc);
//faDoc.Close(false);
return Result.Succeeded;
}
}
}