Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can't Create Instance of Revit Linked File

2 REPLIES 2
Reply
Message 1 of 3
a.slutskij
544 Views, 2 Replies

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. 

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

 
Labels (2)
2 REPLIES 2
Message 2 of 3
joshua.lumley
in reply to: a.slutskij

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

Message 3 of 3
a.slutskij
in reply to: joshua.lumley

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report