在Revit二次开发工作中,或许会用对Curveloop的放大、缩小、偏移等操作。我们查阅开发手册就可以发现Curveloop这个类提供了Transform这个实例方法,有了这个方法我们对Curveloop进行一些操作,下面是一个简单的Demo,通过放大缩小创建了三块楼板。
protected override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
var length = 10000 / 304.8;
var p1 = new XYZ(0, 0, 0);
var p2 = new XYZ(length, 0, 0);
var p3 = new XYZ(length, length, 0);
var p4 = new XYZ(0, length, 0);
var line1 = Line.CreateBound(p1, p2);
var line2 = Line.CreateBound(p2, p3);
var line3 = Line.CreateBound(p3, p4);
var line4 = Line.CreateBound(p4, p1);
var curves = new List<Curve>()
{
line1,line2,line3,line4
};
var curveLoop = CurveLoop.Create(curves);
var sourceArray = new CurveArray();
var expansionArray = new CurveArray();
var reduceArray = new CurveArray();
foreach (var curve in curveLoop)
{
sourceArray.Append(curve);
}
var transform = Transform.Identity.ScaleBasis(1.5);
curveLoop.Transform(transform);
foreach (var curve in curveLoop)
{
expansionArray.Append(curve);
}
curveLoop = CurveLoop.Create(curves);
transform= Transform.Identity.ScaleBasis(0.5);
curveLoop.Transform(transform);
foreach (var curve in curveLoop)
{
reduceArray.Append(curve);
}
RevitDoc.RunTransaction("create floor", () =>
{
RevitDoc.Create.NewFloor(expansionArray, false);
RevitDoc.Create.NewFloor(sourceArray, false);
RevitDoc.Create.NewFloor(reduceArray, false);
});
return Result.Succeeded;
}
标签:Curveloop,curve,Transform,Revit,var,二次开发,new,curveLoop
From: https://www.cnblogs.com/youngala/p/17430553.html