如何能通过API接口找到当前活动文档的SketchPlane?


问题如题


应该可以通过UIDocument.Document.ActiveView.SketchPlane 来获得。


另外View.SketchPlane 是一个可读写的。我们可以利用这个来给一个试图赋值新的工作平面。

看下面代码。 (代码来自:点击打开链接


using System;
using System.Collections.Generic;
using System.Text;
 
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
 
namespace Revit.SDK.Samples.HelloRevit.CS
{
  [Transaction(TransactionMode.Manual)]
  public class Command : IExternalCommand
  {       
    public Result Execute(ExternalCommandData commandData,
      ref string message,
      ElementSet elements)
    {
      UIApplication uiApp = commandData.Application;
      UIDocument uiDoc = uiApp.ActiveUIDocument;
      Transaction transaction =
        new Transaction(uiDoc.Document, "WorkPlane");
      transaction.Start();
 
      Plane plane =
        new Plane(
          uiDoc.Document.ActiveView.ViewDirection,
          uiDoc.Document.ActiveView.Origin);
      SketchPlane sp = uiDoc.Document.Create.NewSketchPlane(plane);
 
      uiDoc.Document.ActiveView.SketchPlane = sp;
      uiDoc.Document.ActiveView.ShowActiveWorkPlane();
      transaction.Commit();
      return Result.Succeeded;
    } 
  }
}


作者:叶雄进

原文链接:

转载请注明出处。http://blog.csdn.net/joexiongjin/article/details/37905079

 




你可能感兴趣的:(如何能通过API接口找到当前活动文档的SketchPlane?)