CAD link status

CAD link status

Anonymous
Not applicable
2,441 Views
7 Replies
Message 1 of 8

CAD link status

Anonymous
Not applicable

Hi all, 

 

I'm trying to get the status of my linked CAD files through RevitAPI, more specifically I want to list all the CAD links that were Not Found. 

 

I know that I'm dealing with ImportInstance, I know that I can use .IsLinked to determine if it was linked or imported. I can't find any way to get the status info, and even finding a path to the original file seems impossible. 

 

Has any of you dealt with this before? Is it even possible? 

 

Many thanks!

0 Likes
Accepted solutions (2)
2,442 Views
7 Replies
Replies (7)
Message 2 of 8

jeremytammik
Autodesk
Autodesk
Accepted solution

I believe that the solution can be found in this discussion:

 

https://thebuildingcoder.typepad.com/blog/2016/08/automatically-reload-links-after-migration.html

 

It includes statements like, 'It took a bit of time to find the right classes as there are no less than four levels of indirection to get from RevitLinkType to the 'Saved Path' and then use that in the call to LoadFrom.'

 

Maybe ExternalFileReference.GetLinkedFileStatus provides what you need:

 

https://www.revitapidocs.com/2020/cd21f80a-f8be-535a-0793-7c113f27c487.htm

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 8

naveen.kumar.t
Autodesk Support
Autodesk Support
Accepted solution

Hi @Anonymous ,

The below code helps you find the status of the link.

 

try using the below code

FilteredElementCollector coll = new FilteredElementCollector(doc).OfClass(typeof(CADLinkType)).WhereElementIsElementType();
                foreach (Element e in coll)
                {
                    ExternalFileReference EX = e.GetExternalFileReference();
                    string linkStatus = EX.GetLinkedFileStatus().ToString();
                }

I hope this helps.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 4 of 8

Anonymous
Not applicable

Fantastic! Thank you both for constructive replies!

0 Likes
Message 5 of 8

Anonymous
Not applicable

Hi, i keep getting "this element does not represent an external file"  when using the solution you provided...

any idea why?

 

thx! 

0 Likes
Message 6 of 8

jeremy_tammik
Alumni
Alumni

Please explore the element you obtain in the debugger and analyse what it really is (class, category, etc.) and what properties it has.

 

Hopefully, that will clarify things.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 7 of 8

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @Anonymous ,

Check out this below link

https://forums.autodesk.com/t5/revit-api-forum/externalfilereference-and-bim-360-project/td-p/7359318 

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 8 of 8

Anonymous
Not applicable

@naveen.kumar.t  @naveen.kumar.t  

thank you for responding, I've read the link. but i'm not using BIM 360, not any plateforme, it's just a central model, and i'm using my local model to extract CAD link status.

 

I copied my code below.  Am i missing something here ?  Thanks.

 

 

namespace TTTTT
{
    [Transaction(TransactionMode.Manual)]
    public class Class1: IExternalCommand
    { 
            public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
            {
                UIApplication uiapp = commandData.Application;
                Document doc = uiapp.ActiveUIDocument.Document;
                FilePath location = new FilePath(@"D:\liu.junquin\Desktop\MN_LABORD_COVIVIO_Local_Junqing LIU.rvt");

                List<object[]> LinkDataList = new List<object[]>();
                FilteredElementCollector CADlinks = new FilteredElementCollector(doc).OfClass(typeof(CADLinkType)).WhereElementIsElementType();
                string msg = "";
                
            foreach (Element link in CADlinks)
                {
                    string _Id, _Name;
                    _Id = link.Id.ToString();
                    _Name = link.Name;
                    ExternalFileReference EX = link.GetExternalFileReference();
                    string linkStatus = EX.GetLinkedFileStatus().ToString();
                msg += linkStatus;
                }
                TaskDialog.Show("status", msg);


                return Result.Succeeded;

            }
        

 

 

0 Likes