### - Please help for getting all linked AutoCAD files in Revit

### - Please help for getting all linked AutoCAD files in Revit

pvirke
Contributor Contributor
565 Views
6 Replies
Message 1 of 7

### - Please help for getting all linked AutoCAD files in Revit

pvirke
Contributor
Contributor
### - Please help for getting all linked AutoCAD files in Revit

Hi All,

 

I am trying to get all the linked AutoCAD files in Revit Api

 

The way I am coding is like the following:
##############################################

// Find all linked AutoCAD Files in the project
FilteredElementCollector cadLinkCollector = new FilteredElementCollector(doc);
cadLinkCollector.OfClass(typeof(ImportInstance)).Cast<ImportInstance>().Where(e => ((ImportInstance)e).IsLinked && ((ImportInstance)e).Category.Name == "Imported Categories");
IList<Element> cadLinks = cadLinkCollector.ToElements();

##############################################

 

But I think something is wrong for the collector method.

Please help me !!!!!!!!!!!!!!!!!!!!!!

0 Likes
566 Views
6 Replies
Replies (6)
Message 2 of 7

Yien_Chao
Advisor
Advisor

hello

 

Where(e => ((ImportInstance)e).IsLinked && ((ImportInstance)e).Category.Name == "Imported Categories")

 

1. what is the "e" after ImportInstance??

2. Category.Name gives the CAD file name like A010.DWG not "Imported Categories"

0 Likes
Message 3 of 7

pvirke
Contributor
Contributor

1. e is the ImportInstance

I can make a definition for it but it won't affect anything;

 2. Category.Name should not be the cad file name, and it should be like "CADLink" or "Imported Categories".

 

What I need is that find out all the linked AutoCAD files in the model and make a Ilist<Element>...

Message 4 of 7

pvirke
Contributor
Contributor

Thanks for your help! Yien!

0 Likes
Message 5 of 7

Yien_Chao
Advisor
Advisor
Strange. On my side it really is the cad file's name.
0 Likes
Message 6 of 7

pvirke
Contributor
Contributor

You're right Yien!

Category.Name is "Link Name" in Revit!
Then how can I get the linked CAD files in Revit?

0 Likes
Message 7 of 7

Sean_Page
Collaborator
Collaborator

Just know that if a link is Not Loaded, then the Category will return a Null.

Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect
0 Likes