您的位置:首页 > 其它

澄清创建参考面函数参数含义

2011-02-23 16:02 316 查看
用API创建族的时候,常常用到创建参考面,可以用 Autodesk.Create.Document.FamilyCreate.NewReferencePlane()方法和NewReferencePlane2() 方法创建. 这里我们只谈第一个函数。因为它有一个向量参数的含义比较模糊。方法二需要指定参考面上的三个点即可。

NewReferencePlane定义如下:

public ReferencePlane NewReferencePlane(
	XYZ bubbleEnd,
	XYZ freeEnd,
	XYZ cutVec,
	View pView
)




他可以用两个点外加一个向量在指定的视图上创建参考面。



这里第三个参数的向量在RevitAPI.chm中的解释是:The cut vector apply to reference plane, should perpendicular to the vector (bubbleEnd-freeEnd). cut vector 的含义好像不是一个专有名词,无法找到解释。这个cutVec向量参数的含义是这个向量必须在需要创建的参考平面的里面,相当于切线向量吧。而不是需要创建参考面的法向量。这一点最容易误解。



知道这个含义就简单了。



例如我们想创建一个水平面上45度斜参考平面。如下参考面。





可以用下面的代码。



using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

using  Autodesk.Revit .DB;
using Autodesk.Revit.UI;
using Autodesk.Revit .ApplicationServices;
using Autodesk.Revit.Attributes ;

  [TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
  [RegenerationAttribute(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
public class RevitCommand : IExternalCommand
{
    public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
    {

      UIApplication app = commandData.Application;
      Document doc = app.ActiveUIDocument.Document;
      Transaction trans = new Transaction(doc, "ExComm");
      trans.Start();

      // create the reference plane.
      XYZ bubbleEnd = new XYZ(5,10,0);
      XYZ freeEnd = new XYZ(10,5,0);
      
      XYZ cutNorm = new XYZ(0,0,1);

      ReferencePlane rp1 = doc.FamilyCreate.NewReferencePlane(bubbleEnd, freeEnd, cutNorm, doc.ActiveView);
      rp1.Name = "my test43";

      trans.Commit();
    
        return Result.Succeeded ;
    }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐