Updating Adaptive Component Reference Points


#1

This was really frustrating to figure out. There should be an AdaptiveComponent.SetLocations node in out-of-the-box Dynamo. Hopefully this will help others having similar problems. Kudos if anyone wants to clean up this code or try and make this work with multiple inputs.

input IN[0] = adaptive component instance
input IN[1] = list of points

import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *
clr.AddReference(‘RevitServices’)
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference(‘RevitNodes’)
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference(‘System’)
from System import *
adaptComp = UnwrapElement(IN[0])
pnts = AdaptiveComponentInstanceUtils.GetInstancePlacementPointElementRefIds(adaptComp)
TransactionManager.Instance.EnsureInTransaction(doc)
for i in range(len(IN[1])):
doc.GetElement(pnts[i]).Position = IN[1][i].ToXyz()
TransactionManager.Instance.TransactionTaskDone()
OUT = 0