if(sel.Elements.Size == 1) { System.Collections.IEnumerator es = sel.Elements.GetEnumerator(); es.MoveNext(); ImportInstance imp = es.Current as ImportInstance; ExternalFileReference el = imp.GetExternalFileReference(); // errors here!!! if (el != null) { directory = ModelPathUtils.ConvertModelPathToUserVisiblePath(el.GetAbsolutePath()); } }
I've been trying to get the file path of a DWG file that is linked into a Revit project. The code above always errors that the ImportInstance is not an external reference but I know the file is linked not imported.
Does anyone know what the difference between an Importinstance and an externalfilereference is?
Solved! Go to Solution.
Solved by jeremy_tammik. Go to Solution.
hi paul,
here is the answer that you provided yourself:
I managed to find a solution:
ImportInstance imp = es.Current as ImportInstance;
if (imp.IsLinked)
{
ExternalFileReference el = ExternalFileUtils.GetExternalFileReference(actdoc, imp.GetTypeId());
if (el != null)
directory = ModelPathUtils.ConvertModelPathToUserVisiblePath(el.GetAbsolutePath());
}
I guess the GetExternalFileReference() isn’t supposed to be exposed in the ImportInstance class like I had tried previously.
cheers,
jeremy
--
Jeremy Tammik
Autodesk Developer Network
http://thebuildingcoder.typepad.com