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

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

pvirke
Contributor Contributor
1,214 Views
7 Replies
Message 1 of 8

### - 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
1,215 Views
7 Replies
Replies (7)
Message 2 of 8

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"

Message 3 of 8

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 8

pvirke
Contributor
Contributor

Thanks for your help! Yien!

0 Likes
Message 5 of 8

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

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 8

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
Senionr Partner, Computational Designer, Architect
0 Likes
Message 8 of 8

lmolina6V6K7
Contributor
Contributor

Hello,

Did you get a valid response here? 

I need to obtain the file path when the CAD link is coming from Autodesk Forma formerly Docs.

0 Likes