Can't Create Instance of Revit Linked File

a.slutskij
Participant
Participant

Can't Create Instance of Revit Linked File

a.slutskij
Participant
Participant

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. 

photo_2020-12-03_20-09-25.jpg

 
0 Likes
Reply
546 Views
2 Replies
Replies (2)

joshua.lumley
Advocate
Advocate

Origin and Shared are the ones you want. (Centered & Site are useless).

0 Likes

a.slutskij
Participant
Participant

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. 

Screenshot_2.png

0 Likes