使用 Revit 创建模型线 API

Create Model Line using Revit API

我尝试在拾取边上创建模型线,但是当我在结构梁上拾取边时,尤其是出现错误。我在下面附上了我的代码和错误图片, 任何人都可以帮助解决这个问题..

在结构梁上拾取边时发生错误

enter image description here

源代码

//Getting Access to Revit
        revitUiApp = commandData.Application;
        revitUi = revitUiApp.ActiveUIDocument;
        revitDoc = revitUi.Document;


        #region Create Model Lines in Picked Reference

        using (Transaction CreateModelLines = new Transaction(revitDoc, "Create Model Lines"))
        {
            CreateModelLines.Start();

            //Pick Plane
            Reference faceRefer = revitUi.Selection.PickObject(ObjectType.Face);

            //Create Sketch Plane
            SketchPlane skp = SketchPlane.Create(revitDoc, faceRefer);

            revitDoc.ActiveView.SketchPlane = skp;

            revitDoc.ActiveView.ShowActiveWorkPlane();

            //Pick Edge to Create Model line
            Reference edgeRefer = revitUi.Selection.PickObject(ObjectType.Edge);

            Edge edge = revitDoc.GetElement(edgeRefer).GetGeometryObjectFromReference(edgeRefer) as Edge;

            Curve Curve = edge.AsCurve();

            revitDoc.Create.NewModelCurve(Curve, skp);


            CreateModelLines.Commit();
        }

        #endregion

已经回答了你的identical question in the Revit API discussion forum