Skip to main content
IntrepidGeophysics
Participant
April 18, 2019
Answered

Obtain filename of referenced graphic

  • April 18, 2019
  • 1 reply
  • 588 views

I am trying to create a script that I can run individually on referenced graphics which would return me information on what file it is, and which document it is located in.

So far I have this script

var graphic = null;

var doc = app.ActiveDoc;

if(doc.ObjectValid() == true)

{

       graphic = doc.FirstSelectedGraphicInDoc;

      

       if(graphic.constructor.name != "Inset")

        {

            graphic = null;

            alert("inset not found");

        }

}

if(graphic != null && graphic.ObjectValid() == true)

{

    var promptMessage = "The currently-selected graphic is:\n\n" +

       graphic.Name +"\n\n" + doc.Name;

        alert(promptMessage);

    }

else

{

    alert("No active document or no referenced graphic selected. " +

        "Cannot continue.");

}

alert("script complete!");

Right now when I have a graphic selected it produces the alert which correctly tells me what document the file is in but says "undefined" in the space I expect to see the image filename.

What is the correct way to obtain this information?

This topic has been closed for replies.
Correct answer frameexpert

The property you want on an imported graphic is not Name but InsetFile.

1 reply

frameexpert
Community Expert
frameexpertCommunity ExpertCorrect answer
Community Expert
April 18, 2019

The property you want on an imported graphic is not Name but InsetFile.

www.frameexpert.com