• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to script anchor allignments with objects?

Community Beginner ,
Apr 11, 2024 Apr 11, 2024

Copy link to clipboard

Copied

Hi,

 

I have to left allign hundreds of symbols - Are these below settings achievable in a script?

Using chatgpt I cant get the code to work in java and wasn't sure if this was possible.

 

rerference.png

TOPICS
Scripting

Views

292

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 11, 2024 Apr 11, 2024

@Niko32511349sm76 

 

This should do the trick:

 

Before:

RobertTkaczyk_2-1712851135125.png

 

After:

RobertTkaczyk_1-1712851103566.png

 

Then you can set properties for the ObjectStyle.

 

Votes

Translate

Translate
Community Expert ,
Apr 11, 2024 Apr 11, 2024

Copy link to clipboard

Copied

Yes, everything you can do manually in UI - can be scripted:

 

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

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 11, 2024 Apr 11, 2024

Copy link to clipboard

Copied

Thank you!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 11, 2024 Apr 11, 2024

Copy link to clipboard

Copied

How can we target the anchored objects? Are they the only anchored objects in the doc? Do they have unique extensions (ie png or psd) from other images in the doc? Do they have Object Styles applied? Are other Object Styles in use in thr doc?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 11, 2024 Apr 11, 2024

Copy link to clipboard

Copied

The object is a library element that I just tend to copy and paste into the text box and then anchor accordingly. These symbols are the only anchored object in the doc and have no object styles apploed.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 11, 2024 Apr 11, 2024

Copy link to clipboard

Copied

@Niko32511349sm76 

 

This should do the trick:

 

Before:

RobertTkaczyk_2-1712851135125.png

 

After:

RobertTkaczyk_1-1712851103566.png

 

Then you can set properties for the ObjectStyle.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 11, 2024 Apr 11, 2024

Copy link to clipboard

Copied

Screenshot 2024-04-11 at 17.11.07.png

 

I have set this up but I dont think its recognising the symbols an an object? Coming up as found 0 object. For more detail - they are symbols created in illustrator that are imported into our libraries.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 11, 2024 Apr 11, 2024

Copy link to clipboard

Copied

@Niko32511349sm76 

 

Can you share a sample document? Can be on priv - click my nickname.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 11, 2024 Apr 11, 2024

Copy link to clipboard

Copied

Try a find for [Basic Graphics Frame] instead of [None]

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 11, 2024 Apr 11, 2024

Copy link to clipboard

Copied

Or, click on one of the objects and see what Object Style is applied. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 11, 2024 Apr 11, 2024

Copy link to clipboard

Copied

LATEST

Hi @Niko32511349sm76,  this script tries to do what you want. You need to set up the object style first, and put the correct name for the object style into the script (replace 'My Object Style Here').

- Mark

 

/**
 * Apply Object Style To All Anchored Objects
 * @author m1b
 * @discussion https://community.adobe.com/t5/indesign-discussions/how-to-script-anchor-allignments-with-objects/m-p/14549295
 */
function main() {

    var anchoredObjectStyleName = 'My Object Style Here';

    var doc = app.activeDocument,
        objectStyle = doc.objectStyles.itemByName(anchoredObjectStyleName);

    if (!objectStyle.isValid)
        return alert('Could not find object style "' + anchoredObjectStyleName + '".');

    doc.stories.everyItem().pageItems.everyItem().appliedObjectStyle = objectStyle;

};
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Apply Object Style To Anchored Objects');

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines