• 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 check the collision anchored object in indesign

Community Beginner ,
Nov 17, 2017 Nov 17, 2017

Copy link to clipboard

Copied

Hi All,

I have a catalog with contact details and Photo in margin. There are 1000+ data in a file and the file count is 100+ (Government youth enrollment data). Where are there are few photo height which exceeds it content length, which leads to cut off the following photo. Is there any algorithm in java script to identify the collision objects? IF we check every object against every other object it might take more time.

TOPICS
Scripting

Views

300

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
People's Champ ,
Nov 17, 2017 Nov 17, 2017

Copy link to clipboard

Copied

LATEST

Probably not bulletproof but here is an approach:

#targetengine "overlaps"

var w = w || getWindow();

w.show();

function getWindow() {

var objs;

var w = new Window("palette");

w.alignChildren = ["fill","top"];

w.preferredSize.width = 200;

var ls = w.add("ListBox");

ls.onChange = function() {

if (!ls.selection || !objs ) {

app.select ( NothingEnum.NOTHING );

return;

}

app.select( objs[ls.selection.text] );

}

ls.preferredSize.height = 300;

var b = w.add('button', undefined, 'Refresh' );

w.add('button',undefined,'Cancel');

w.onShow = b.onClick = function() {

ls.removeAll();

objs  = getObjects();

if ( !objs || !objs.ids ) {

return;

}

var n =  objs.ids.length, i = 0;

while ( i< n) {

ls.add('item', objs.ids );

i++;

}

}

return w;

}

function getObjects() {

var doc = app.properties.activeDocument,

fgp = app.findGrepPreferences.properties, found,

n = 0, prevItem, nextItem, currItem, overlaps = {}, currVB, prevVB, currChar, prevChar, ids = [];

if ( !doc ) return;

app.findGrepPreferences.properties = {

findWhat:"~a"

}

found = doc.findGrep();

n = found.length;

while ( n-- ) {

currChar = found;

currItem = currChar.pageItems[0];

prevChar = found[n-1];

if ( !prevChar ) continue;

prevItem = prevChar.pageItems[0];

if ( currChar.parentTextFrames.length

&& prevChar.parentTextFrames.length

&& prevChar.parentTextFrames[0].id == currChar.parentTextFrames[0].id ) {

currVB = currItem.visibleBounds;

prevVB = prevItem.visibleBounds;

$.writeln( "ici" );

if (

( currVB[0] >  prevVB[0] && currVB[0] < prevVB[2] )

||

( currVB[1] >  prevVB[1] && currVB[1] < prevVB[3] )

) {

overlaps[currItem.id] = currItem ;

ids.push(  currItem.id );

}

}

}

overlaps.ids = ids;

return overlaps;

}

Capture d’écran 2017-11-17 à 17.47.35.png

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