External Files

External Files

Anonymous
Not applicable
437 Views
1 Reply
Message 1 of 2

External Files

Anonymous
Not applicable

Hi,

 

The following code gets all the files linked or imported in a revit document but how do I get the list of cad files that are linked and not imported:

 

ModelPath location = ModelPathUtils.ConvertUserVisiblePathToModelPath(doc.PathName);
string path = ModelPathUtils.ConvertModelPathToUserVisiblePath(location);

TransmissionData transData = TransmissionData.ReadTransmissionData(location);
ICollection<ElementId> externalReferences = transData.GetAllExternalFileReferenceIds();

foreach (ElementId refId in externalReferences)
{
ExternalFileReference extRef = transData.GetLastSavedReferenceData(refId);

string ipath=ModelPathUtils.ConvertModelPathToUserVisiblePath(extRef.GetPath());
if (ipath.Contains(".dwg"))
{
string fileName = Path.GetFileName(ipath);
categoryname.Add(fileName);
}

}

 

Thanks & Regards

Sanjay Pandey

Accepted solutions (1)
438 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Accepted solution

Hello sanjay,

 

You can use a FilteredElementCollector

 

foreach (ImportInstance ii in  new FilteredElementCollector(document)
        .OfClass(typeof(ImportInstance))
        .Cast<ImportInstance>()
        .Where(i => i.IsLinked == true))
{

Do something....
}

 Good Luck

 

/Martin

0 Likes