创建一个族和创建一个族类型

using System;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyApp
{
[Transaction(TransactionMode.Manual)]
public class Command : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
Document revitDoc = commandData.Application.ActiveUIDocument.Document; //取得文档
UIApplication uiApp = commandData.Application;
Application revitApp = commandData.Application.Application; //取得应用程序
Document familydoucment = revitApp.NewFamilyDocument(@“C:\ProgramData\Autodesk\RVT 2018\Family Templates\Chinese\A公制常规模型.rft”);
using (Transaction transaction = new Transaction(familydoucment))
{
transaction.Start(“123”);
CurveArray curveArray = new CurveArray();
curveArray.Append(Line.CreateBound(new XYZ(0, 0, 0), new XYZ(5, 0, 0)));
curveArray.Append(Line.CreateBound(new XYZ(5, 0, 0), new XYZ(5, 5, 0)));
curveArray.Append(Line.CreateBound(new XYZ(5, 5, 0), new XYZ(0, 5, 0)));
curveArray.Append(Line.CreateBound(new XYZ(0, 5, 0), new XYZ(0, 0, 0)));
CurveArrArray curveArrArray = new CurveArrArray();
curveArrArray.Append(curveArray);
Frame frame = new Frame();
//Frame frame = new Frame(XYZ.Zero, new XYZ(1, 0, 0),);
//Plane plane = Plane.CreateByNormalAndOrigin(new XYZ(0, 0, 1), XYZ.Zero);
Plane plane = Plane.CreateByNormalAndOrigin(new XYZ(0, 0, 1), new XYZ(0, 10, 100));

            SketchPlane sketchPlane = SketchPlane.Create(familydoucment, plane);

            familydoucment.FamilyCreate.NewExtrusion(true, curveArrArray, sketchPlane, 100)  ;
            familydoucment.FamilyManager.NewType("溜溜溜溜");

            transaction.Commit();
            familydoucment.SaveAs(@"C:\Users\cui\Desktop\trt\trt678.rfa");
            familydoucment.Close();


        }

            return Result.Succeeded;
    }
}

}

你可能感兴趣的:(revit二次开发)