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!
Solved! Go to Solution.
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!
Solved! Go to Solution.
Solved by naveen.kumar.t. Go to Solution.
Solved by jeremytammik. Go to 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
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
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.
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.
Fantastic! Thank you both for constructive replies!
Fantastic! Thank you both for constructive replies!
Hi, i keep getting "this element does not represent an external file" when using the solution you provided...
any idea why?
thx!
Hi, i keep getting "this element does not represent an external file" when using the solution you provided...
any idea why?
thx!
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.
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.
Hi @Anonymous ,
Check out this below link
Hi @Anonymous ,
Check out this below link
@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;
}
@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.