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: 

Find RevitLinks is Loaded or UnLoaded

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
VinoVinoth92
3676 Views, 10 Replies

Find RevitLinks is Loaded or UnLoaded

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

10 REPLIES 10
Message 2 of 11

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


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Message 3 of 11

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

Message 4 of 11

@VinoVinoth92

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


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Message 5 of 11

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.

Message 6 of 11

Apologies, it's a static method. I have edited the code in the post.


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Message 7 of 11

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

Message 8 of 11
FAIR59
in reply to: VinoVinoth92

I found this Utility, maybe it gives the results you require

 

RevitLinkUIUtils.ReportLinkLoadResults()

 

 

Message 9 of 11
matthew_taylor
in reply to: FAIR59

@VinoVinoth92

No, no problem!

 

@FAIR59

I don't think so, but I'm happy to be enlightened!


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Message 10 of 11
FAIR59
in reply to: FAIR59

@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 11 of 11

Message 10  is the solution.
Message 10  is the solution.
Message 10  is the solution.

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community