Can't Create Instance of Revit Linked File
Hello everyone, I ran into the problem of connecting Revit Links files via the API. Only ImportPlacement.Origin works fine. Other ImportPlacement settings throw exceptions like on the screenshot.
The coordinate system in the source file and in the link file are similiar. If I am loading Linked Revit files via the standart Links Manager work everything loads fine.
void LoadLink(Document doc, string LinkPath, bool isRelative, ImportPlacement importPlacement)
{
try
{
using (Transaction transaction = new Transaction(doc, "Load Linked Project2"))
{
transaction.Start();
ModelPath linkPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(LinkPath);
RevitLinkOptions options = new RevitLinkOptions(true);
LinkLoadResult result = RevitLinkType.Create(doc, linkPath, options);
if (result.LoadResult != LinkLoadResultType.LinkLoaded)
{
TaskDialog.Show("Неудача", $"Не удалось привязать связанный файл: {result.LoadResult.ToString()}");
}
else
{
RevitLinkInstance revitLinkInstance = RevitLinkInstance.Create(doc, result.ElementId, importPlacement);
}
transaction.Commit();
}
}
catch (Exception ex)
{
TaskDialog.Show("Ошибка", $"Не удалось привязать связанный файл: {ex.Message}");
}
}
The APIdocs states that some of the ImportPlacement settings need a reference point to work, but I haven't encountered this concept before.
Link copied