Resize anchored objects with script as per the item width

Participant ,
Sep 02, 2022 Sep 02, 2022

Copy link to clipboard

Copied

I have created this custom leader which is a line (it may be a vector graphic as well).
Currently I have anchored this line after the page number and given it an object style.

Issue is that all the Table of Contents items are not of uniform size so the line is
overlapping the TOC items.

I wanted to write a script which will automatically reduce the size of the anchored line
or graphic from right side (for vector graphics, i'll put the vector inside the box and
change the size of the box as per requirement).


My knowledge of indesign script is nil. I do have some idea of coding.

Somehow I got the following code to get the number of anchored objects.

I modified the code but it aint working. Nothing happens. It only shows
the count of anchored object which again is a matter of concern as there are other anchored objects which
I dont want to touch. It should only read the vectors I use instead of leaders.

 

Screenshot attached.

 

Here is the code:

---------------------------

allAnchObjects = app.activeDocument.stories.everyItem().pageItems.everyItem().getElements();
for (i=0; i<allAnchObjects.length; i++)
{
alert(allAnchObjects.length);
//allAnchObjects[i].resize (BoundingBoxLimits.GEOMETRIC_PATH_BOUNDS,AnchorPoint.TOP_LEFT_ANCHOR,ResizeMethods.ADDING_CURRENT_DIMENSIONS_TO,[ 0, 10 ]);
//Set the anchor point to the left side. Meaning Lock the left side.
app.activeDocument.layoutWindows[0].transformReferencePoint = AnchorPoint.LEFT_CENTER_ANCHOR;

//allAnchObjects[i].resize (BoundingBoxLimits.GEOMETRIC_PATH_BOUNDS,AnchorPoint.RIGHT_CENTER_ANCHOR,ResizeMethods.ADDING_CURRENT_DIMENSIONS_TO,[ 0, 10 ]);
allAnchObjects[i].resize (BoundingBoxLimits.GEOMETRIC_PATH_BOUNDS,AnchorPoint.LEFT_CENTER_ANCHOR,ResizeMethods.ADDING_CURRENT_DIMENSIONS_TO,[ 0, 10 ]);
}

 

Thanks and regards

TOPICS
How to , Scripting

Views

48

Likes

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
Advocate ,
Sep 03, 2022 Sep 03, 2022

Copy link to clipboard

Copied

How about Character Style with underline applied only to the Tab in between? 

---
Can automate anything - as long as it doesn't require A.I. 😉 and even then 3rd helping hand can be created 😉

Likes

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
Participant ,
Sep 03, 2022 Sep 03, 2022

Copy link to clipboard

Copied

Thanks for the idea. I do have that in mind, however my main concern is that I want to use vector image (a divider line) in place of leaders. Thats the reason I need something to resize automatically the "vector leaders" as per the TOC items. 

 

Regards

Likes

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
Advocate ,
Sep 03, 2022 Sep 03, 2022

Copy link to clipboard

Copied

LATEST

If you really need this horrible line 😉 then in script you should be checking horizontal location of the InsertionPoint after the tab - to calculate the length of this "line". 

---
Can automate anything - as long as it doesn't require A.I. 😉 and even then 3rd helping hand can be created 😉

Likes

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