Pick New Host from the API?

revit

#1

Hello, everybody!
I looked through the API docs and I couldn’t find anything, but I might still be missing something here.
Is there an analog to Pick New Host in the API?



#2

Did you ever find an answer to this? I’m looking for the same question’s answer.


#3

The property HostId can be retrieved and set, so this Python script should do it:

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

doc = DocumentManager.Instance.CurrentDBDocument

railing = UnwrapElement(IN[0])
newhost = UnwrapElement(IN[1])

TransactionManager.Instance.EnsureInTransaction(doc)

hostId = newhost.Id
railing.HostId = hostId

TransactionManager.Instance.TransactionTaskDone()

OUT = railing

#4

I totally forgot I made this topic.
I eventually found the HostId thing and it turned out to be straightforward. The thing I was working on though took another way so I never used it.
The sample script from @awilliams is working and it’s great.