Doing family library during this period, when needed to connect with Revit at the end, hoping users can choose to download and then directly arrange components in Revit. Searching API, found PromptForFamilyInstancePlacementOptions method can be used to implement family placement.

The code is relatively simple, but need to remember, since PromptForFamilyInstancePlacementOptions will create a transaction itself, so if using it, need to move this method out of transaction.

code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Family family;

using (Transaction trans = new Transaction(app.ActiveUIDocument.Document,"load family"))
{
trans.Start();

var loadFamily = app.ActiveUIDocument.Document.LoadFamily(
localPath + ttn.Name + ".rfa", new RevitLoadFamily(),
out family);

//If download fails then prompt
if (!loadFamily)
{
MessageBox.Show(ttn.Name +
$"cant find the family , \r\n localPath:{localPath + ttn.Name + ".rfa"}");
return;
}

trans.Commit();
}

var symbol =
app.ActiveUIDocument.Document.GetElement(family.GetFamilySymbolIds().First()) as
FamilySymbol;

app.ActiveUIDocument.PromptForFamilyInstancePlacement(symbol);