如何编程创建自适应构件对象

2025-04-19 22:30:41
推荐回答(1个)
回答1:

先创建一个对象,然后为每一个点设置坐标。

[csharp] view plain copy
private void CreateAdaptiveComponentInstance(Document document, FamilySymbol symbol)
{
// Create a new instance of an adaptive component family
FamilyInstance instance = AdaptiveComponentInstanceUtils.CreateAdaptiveComponentInstance(document, symbol);

// Get the placement points of this instance
IList placePointIds = new List();
placePointIds = AdaptiveComponentInstanceUtils.GetInstancePlacementPointElementRefIds(instance);
double x = 0;

// Set the position of each placement point
foreach (ElementId id in placePointIds)
{
ReferencePoint point = document.GetElement(id) as ReferencePoint;
point.Position = new Autodesk.Revit.DB.XYZ(10*x, 10*Math.Cos(x), 0);
x += Math.PI/6;
}
}