Revit 2018二次开发 创建草图平面SketchPlane

Revit 2018二次开发 创建草图平面SketchPlane,分为两步

Plane plane = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, XYZ.Zero);
SketchPlane modelSketch = SketchPlane.Create(RevitDoc, plane);

先做Plane,后做SketchPlane

整段代码示例

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

            using (Transaction transaction = new Transaction(RevitDoc))
            {
                transaction.Start("Create Model Line");
                Line geoLine = Line.CreateBound(XYZ.BasisY * 10, XYZ.BasisX * 10);
                Plane plane = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, XYZ.Zero);
                SketchPlane modelSketch = SketchPlane.Create(RevitDoc, plane);
                ModelCurve modelLine = RevitDoc.Create.NewModelCurve(geoLine, modelSketch);
                transaction.Commit();
            }







            return Result.Succeeded;

        }
    }
}


你可能感兴趣的:(学习历程,c#)