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: 

external reference versus importinstance

1 REPLY 1
SOLVED
Reply
Message 1 of 2
phildebrandt
820 Views, 1 Reply

external reference versus importinstance

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?

1 REPLY 1
Message 2 of 2

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

 

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open

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