Revit二次開發(fā)-Curveloop的放大和縮小
在Revit二次開發(fā)工作中,或許會用對Curveloop的放大、縮小、偏移等操作。我們查閱開發(fā)手冊就可以發(fā)現(xiàn)Curveloop這個類提供了Transform這個實例方法,有了這個方法我們對Curveloop進(jìn)行一些操作,下面是一個簡單的Demo,通過放大縮小創(chuàng)建了三塊樓板。
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;
}

原文鏈接:https://www.dianjilingqu.com/746770.html