Revit2018复现《AUTODESK REVIT二次开发基础教程》代码15

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 LearnTime
{
    //必备写法
    [Transaction(TransactionMode.Manual)]
    [Journaling(JournalingMode.NoCommandData)]
    [Regeneration(RegenerationOption.Manual)]
    class _15_CreatReferencePlane : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIDocument uiDoc = commandData.Application.ActiveUIDocument;
            Document doc = commandData.Application.ActiveUIDocument.Document;

            if (!doc.IsFamilyDocument)
                return Result.Failed;

            using (Transaction transaction = new Transaction(doc, "Editing Family"))
            {
                transaction.Start();
                XYZ bubbleEnd = new XYZ(0, 5, 5);
                XYZ freeEnd = new XYZ(5, 5, 5);
                XYZ cutVector = XYZ.BasisY;
                View view = doc.ActiveView;
                ReferencePlane referencePlane = doc.FamilyCreate.NewReferencePlane(bubbleEnd, freeEnd, cutVector, view);
                referencePlane.Name = "MyReferencePlane";
                transaction.Commit();
            }


            return Result.Succeeded;

        }
    }
}
 

你可能感兴趣的:(AUTODESK,c#)