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 set the position of each point mathematically.
Code Region: Creating an Instance of an Adaptive Component Family |
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<ElementId> placePointIds = new List<ElementId>(); 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; } } |
To batch create adaptive components, you can use the overload of the FamilyInstanceCreationData constructor that takes two parameters - a FamilySymbol and a list of XYZ adaptive points where the adaptive instance is to be initialized . In conjunction with the Autodesk.Revit.Creation.ItemFactoryBase.NewFamilyInstances2() method which takes a list of FamilyInstanceCreationData objects, multiple adaptive components can be added at once. This may be more efficient than placing individual adaptive components one-by-one.