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.
I am developing plug-in for butch loading Linked Files with all possible settings. In our company we are using Site setting (From Base point to Base point) for loading Linked Files. Shared setting is not working too. It is strange, because the same coordinate system was shared to the linked file before loading.
Can't find what you're looking for? Ask the community or share your knowledge.