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: 

CAD link status

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Anonymous
1829 Views, 7 Replies

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

CAD link status

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!

7 REPLIES 7
Message 2 of 8
jeremytammik
in reply to: Anonymous

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

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
in reply to: Anonymous

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

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
in reply to: naveen.kumar.t

Anonymous
Not applicable

Fantastic! Thank you both for constructive replies!

0 Likes

Fantastic! Thank you both for constructive replies!

Message 5 of 8
Anonymous
in reply to: naveen.kumar.t

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

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

any idea why?

 

thx! 

Message 6 of 8
jeremy_tammik
in reply to: Anonymous

jeremy_tammik
Autodesk
Autodesk

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

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
Message 7 of 8
naveen.kumar.t
in reply to: Anonymous

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

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

Message 8 of 8
Anonymous
in reply to: jeremy_tammik

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

@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;

            }
        

 

 

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

Post to forums  

Autodesk Design & Make Report