Adaptive Components

Adaptive Components

Adaptive Components are designed to handle cases where components need to flexibly adapt to many unique contextual conditions. For example, adaptive components could be used in repeating systems generated by arraying multiple components that conform to user-defined constraints.

The following code shows how to create an instance of an adaptive component family into a massing family and align the adaptive points in the instance with points in the massing family.

Code Region: Creating an Instance of an Adaptive Component Family

// find the first placement point that will host the adaptive component
IEnumerable<ReferencePoint> points0 = from obj in new FilteredElementCollector(doc).OfClass(typeof(ReferencePoint)).Cast<ReferencePoint>()
    let type = obj as ReferencePoint
    where type.Name == "PlacementPoint0" // these names were manually assigned to the points
    select obj;
ReferencePoint placementPoint0 = points0.First();

// find the 2nd placement point that will host the adaptive component
IEnumerable<ReferencePoint> points1 = from obj in new FilteredElementCollector(doc).OfClass(typeof(ReferencePoint)).Cast<ReferencePoint>()
    let type = obj as ReferencePoint
    where type.Name == "PlacementPoint1"
    select obj;
ReferencePoint placementPoint1 = points1.First();

if (AdaptiveComponentInstanceUtils.IsAdaptiveFamilySymbol(symbol))
{
    // create an instance of the adaptive component
    FamilyInstance familyInstance = AdaptiveComponentInstanceUtils.CreateAdaptiveComponentInstance(doc, symbol);

    // find the adaptive points in the family instance
    IList>ElementId> pointList = AdaptiveComponentInstanceUtils.GetInstancePointElementRefIds(familyInstance);
    ReferencePoint point0 = doc.GetElement(pointList.ElementAt(0)) as ReferencePoint;
    ReferencePoint point1 = doc.GetElement(pointList.ElementAt(1)) as ReferencePoint;

    // move the adaptive component's points (point0 & point1) to match the position of the placement points
    point0.Position = placementPoint0.Position;
    point1.Position = placementPoint1.Position;
}