Skip to main content
November 13, 2009
Answered

I need to fix 4000 inline graphic boxes

  • November 13, 2009
  • 3 replies
  • 1536 views

Hello,

I need to fix 4000 inline graphic boxes because InDesign CS4 treats corner effects diiferently than in CS3.

See the problem here: http://indesignsecrets.com/cs4-treats-rounded-corner-objects-differently.php

Because the designers used this trick, I need to fix all the inline graphic boxes in CS4 for a reprint. All the inline graphic frames are suppose to just have one corner that is rounded. Short of selecting every frame individually and converting it to a rectangle, then running the Corner Effect Script on each one, I was wondering if there was a way to write a script that:

1 Selects all inline graphic text frames with certain attributes like fill color.

2 Converts all of those boxes to rectangles (Because the way they were made, they currently have 7 points)

3 Runs the Corner Effect Script on each box for only rounding the fourth corner.

Any suggestions?

Rob

This topic has been closed for replies.
Correct answer Harbs.

Harbs,

Your the best! This is going to save me a lot of time and frustration. I've heard Anne-Marie sing your praises before on the InDesign Secret podcast. I'm so thankful you helped me.

The reason I am still getting the error is because there is an additional element I didn't have in the original document I uploaded. I have uploaded a new document to show you. There is another inline graphic in the document that is causing the error. It is a graphics frame that is grouped with a text frame that was then made an inline graphic. The script stops at this frame.

I know very little about scripting, but is there a way to say if the inline graphic is grouped, then ignore it? I think the script gets the error because it doesn't know what to do with inline text frames that are grouped.

Many Thanks,

Rob


Just add in a line like this:

for (var i=0;i<inlines.length;i++){

  if (inlines instanceof Group){continue}

  if(inlines.fillColor != color){continue}

3 replies

November 21, 2009

I thought it was kind of odd to redraw the inline graphic 4000 times. Instead I created a new page item by drawing a rectangle to the dimensions of the inline item I'd want to replace. (Or I could copy out the inline graphic, then convert it to a rectangle under the Object menu.) Then just run the "CornerEffects.applescript" script from ID's script menu. Add any other effects you'd like. Give the new item a script label (Windows/Automation/Script Label).

Then run this applescript:

tell application "Adobe InDesign CS3"
    --selects the new item you made and labeled and copies it to the clipboard
    select (first page item of document 1 whose label is "yourlabel")
    copy

--now get your inline graphics based on a property; ignore inline object that are groups
    set myItems to (get every page item of (every story of document 1))
    repeat with anItem in myItems
        if class of anItem is not group then
            if name of fill color of anItem is "yourcolor" then
                select insertion point 1 of parent of anItem

--paste the contents of the clipboard which is the new item
                paste
                --delete the old inline item
                delete anItem
            end if
        end if
    end repeat

It's low-tech, but I'm a low-tech kind of guy.

Cheers

Greg

November 24, 2009

Thank you for taking the time to help me with this issue, Greg!

It is much appreciated. I'm trying to tweak the script right now to find the frames I need.

Thanks again!

Rob

Harbs.
Legend
November 17, 2009

This should do the trick (untested):

var doc = app.documents[0]
var color = doc.colors.item("My Color");
var inlines = doc.stories.everyItem().pageItems.everyItem().getElements();
for(var i=0;i<inlines.length;i++){
    if(inlines.fillColor != color){continue}
    inlines.convertShape(ConvertShapeOptions.CONVERT_TO_RECTANGLE);
    myChangeCorners(inlines, 0, 12, "fourth point");
}

You would obviously need to copy the functions from the CornerEffects script as well...

Change the "12" to whatever inset you need.

November 17, 2009

Wow!

Thank you for responding Harbs!

I get error number 11282 when I try to run the script.

"The content of this object has multiple values for this graphic attribute."

For this line:

for(var i=0;i<inlines.length;i++)

Is there something I need to change?

Thanks again!

Rob

PS I have attached the document I am trying to fix. It is the "Strategy" and "Skill" box I want to select, convert to a rectangle, then run the fourth point corner option. Any help would be much appreciated.

November 18, 2009

It seems to work fine for me.

I zipped the whole script for you...


Harbs,

Your the best! This is going to save me a lot of time and frustration. I've heard Anne-Marie sing your praises before on the InDesign Secret podcast. I'm so thankful you helped me.

The reason I am still getting the error is because there is an additional element I didn't have in the original document I uploaded. I have uploaded a new document to show you. There is another inline graphic in the document that is causing the error. It is a graphics frame that is grouped with a text frame that was then made an inline graphic. The script stops at this frame.

I know very little about scripting, but is there a way to say if the inline graphic is grouped, then ignore it? I think the script gets the error because it doesn't know what to do with inline text frames that are grouped.

Many Thanks,

Rob

November 14, 2009

Mac or PC?

November 16, 2009

Either would be fine. Mac is perferred.

November 17, 2009

Sorry, having trouble with my Applescripting. I can get a script to delete in line graphics based on its type (like delete every oval of every text flow) and I can insert an inline graphic form the clipboard based on a specific paragraph style (if paragraph i of text flow j is "paragraphstyle" then tell insertion point 1 to paste). However, I'm not able (as of yet) to just find and replace the object. You may be pressed for time, and I'm not sure when I can get back to this (I usually script on the weekends).