Hi,
I want to find all the available RevitLinkTypes in a revit document was Loaded or Unloaded. Kindly help me to accomplish this.
Thanks and Regards,
Vinoth Kumar.R
Solved! Go to Solution.
Solved by matthew_taylor. Go to Solution.
Hi Vinoth,
Head over to http://www.revitapidocs.com and search for RevitLinkType. You'll find an isLoaded property.
And this single line of code should get you everything else you need:
Dim ids As ICollection(Of DB.ElementId) = DB.ExternalFileUtils.GetAllExternalFileReferences(doc)
The first piece of information you should have searched for yourself!
The second is a bit less easy to find...
Maybe you could post your results?
Cheers,
-Matt
Hi Matt,
Actually I have got all the RevitLinkTypes in the Document but the revit link types not having any property like "IsLoaded" etc. First thing i have tried and I have searched via Revit LookUp after that i have posted in forums. The code you have provided which will return collection of ElementIds which was referenced to that document. We have to get the elements from the document using collection of ids. But the element class not having property "IsLoaded".
Thanks and Regards,
Vinoth Kumar.R
A RevitLinkType is a type of object that inherits from 'Element', so you need to cast the Element to a RevitLinkType.
This is one of the basic things that you need to do a lot of when using the Revit API. You would do well to spend time looking at the SDK and sites such as thebuildingcoder. You will learn a lot by reading examples. 🙂
So.
[Edit]
If DB.RevitLinkType.IsLoaded(doc, elemId) Then ....
[/Edit]
Let us know how you get on.
Cheers,
-Matt
Hi Matt,
ICollection<ElementId> colls = ExternalFileUtils.GetAllExternalFileReferences(doc);
if (colls.Count > 0)
{
foreach(var id in colls)
{
Element ele = doc.GetElement(id);
if (ele != null)
{
RevitLinkType rvtLinkType = (RevitLinkType)ele;
rvtLinkType.IsLoaded
}
}
}
Please refer this code snippet as you have mentioned it does not having any property like IsLoaded. I know Which class was derived from which class. Please open Revit 2016 and try this. Thanks for the advice.
Thanks and Regards,
Vinoth.
Apologies, it's a static method. I have edited the code in the post.
Hi Matt,
Why apologies and all. Forgive me If my words hurt you. I will check through that static method. Thanks for the reply.
Thanks and Regards,
Vinoth Kumar.R
I found this Utility, maybe it gives the results you require
RevitLinkUIUtils.ReportLinkLoadResults()
No, no problem!
I don't think so, but I'm happy to be enlightened!
@matthew_taylor, you're right, the utility isn't the solution.
Still there is a simple test:
RevitLinkInstance RevitLink = Elem as RevitLinkInstance;
Document link = RevitLink.GetLinkDocument();
link==null : link is unloaded
link!=null : link is loaded
Message 10 is the solution.
Message 10 is the solution.
Message 10 is the solution.