Skip to main content
Inspiring
May 3, 2021
Question

InDesign find object preferences

  • May 3, 2021
  • 3 replies
  • 535 views

I need to search for every empty graphic frame in my document, export it as PNG, and re-import the PNG into the frame.

 

Before I can find, though, it seems I need to set the proper setting:

 

Tried the following but keep getting an error:

app.findObjectPreferences.objectType = ObjectTypes.GRAPHIC_FRAMES_TYPE;
 
Message returned: 
Error Code# 55: Object does not support the property or method 'objectType' @ file '~/Documents/Tweak/InDesign/Graphic%20Frame%20Fix.jsx'
 
How do I set the preference and get an array of the objects?
    This topic has been closed for replies.

    3 replies

    Community Expert
    May 4, 2021

    Hi Tim,

    I don't know what you expect with a search on Graphic Frame Type.

     

    You'll find only objects that are created with the graphic frame tools:

    UITools.POLYGON_FRAME_TOOL
    UITools.RECTANGLE_FRAME_TOOL
    UITools.ELLIPSE_FRAME_TOOL

     

    You will not find frames created with:

    UITools.POLYGON_TOOL
    UITools.RECTANGLE_TOOL
    UITools.ELLIPSE_TOOL

     

    Sample code:

    app.findChangeObjectOptions.properties =
    {
    	includeFootnotes : true ,
    	includeHiddenLayers : true ,
    	includeLockedLayersForFind : true ,
    	includeLockedStoriesForFind : true ,
    	includeMasterPages : true ,
    	
    	objectType : ObjectTypes.GRAPHIC_FRAMES_TYPE
    };
    
    app.findObjectPreferences = null ;
    
    // Scope is the active document:
    var doc = app.documents[0];
    var resultArray = doc.findObject();
    
    // Change the fill color of all found objects to "Yellow":
    for( var n=0; n<resultArray.length; n++ )
    {
    	resultArray[n].fillColor = doc.colors.itemByName( "Yellow" );
    };

     

    Run this code against a document that contains only two rectangles; one recatngle done with the Rectangle Frame tool, the other one with the Rectangle tool:

     

     

     

    After running the script:

     

     

    Only the frame done with the Rectangle Frame tool was found and fill color was changed.

     

    Regards,
    Uwe Laubender

    ( ACP )

    Community Expert
    May 3, 2021

    Hi Tim,

    your InDesign is right.

    objectType is not part of app.findObjectPreferences.

    You'll find that in app.findChangeObjectOptions.

     

    See into ExtendScript's DOM documentation for InDesign compiled by Gregor Fellenz:

    https://www.indesignjs.de/extendscriptAPI/indesign-latest/#FindChangeObjectOption.html#d1e337707

     

    Regards,
    Uwe Laubender

    ( ACP )

    Inspiring
    May 3, 2021

    Thanks for your input. I saw that there is also an app.findOjectOptions in the link you posted. But is there another way to get the objects.

     

    I have written a few scripts that have been very useful for me but I am having trouble working out exactly where to address objects in the DOM.

     

    How do I get an array of all page Items that are ObjectTypes.GRAPHIC_FRAMES_TYPE

     

     

    Peru Bob
    Community Expert
    Community Expert
    May 3, 2021

    I've moved this from the Using the Community forum (which is the forum for issues using the forums) to the InDesign forum so that proper help can be offered.