认识点(XYZ)和线(Curve)
- 点和线是看不到的用它来创建元素,比如基于点的用XYZ基于线的用Curve的子类Line或Arc
- 点XYZ
- 创建点为new XYZ(X,Y,z)
- 线 Curve子类有Line和Arc
- Line创建:Line.Create (xyz1,xyz2)
- Arc创建: Arc.Create()
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using pro.util;
namespace pro
{
[Transaction(TransactionMode.Manual)]
public class Class1 : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIApplication uiApp = commandData.Application;
UIDocument uIDocument = uiApp.ActiveUIDocument;
Document document = uIDocument.Document;
//可载入族的族类型和族获取方式
FamilyInstance door = document.GetElement(new ElementId(338289)) as FamilyInstance;
//得到门的点
XYZ xyz = (door.Location as LocationPoint).Point;
Wall wall = document.GetElement(new ElementId(336406)) as Wall;
//得到墙的线
Curve curve = (wall.Location as LocationCurve).Curve;
XYZ startXyz = curve.GetEndPoint(0);
XYZ endXyz = curve.GetEndPoint(1);
Line wallLine = curve as Line;
return Result.Succeeded;
}
}
}