set aList to retGeometricBounds() of me
–(InDesign上の選択アイテムから取得した座標値のうち)リストの最初の項目は原点の座標だ、という経験則から set originData to contents of first item of aList
set y1Max to contents of item 1 of first item of shellSortListDecending(aList, 1) of me –y1でソートして最大のものをリストアップ
(*
set y1Min to contents of item 1 of first item of shellSortListAscending(aList, 1) of me –y1でソートして最小のものをリストアップ
set x1Max to contents of item 2 of first item of shellSortListDecending(aList, 2) of me –x1でソートして最大のものをリストアップ set x1Min to contents of item 2 of first item of shellSortListAscending(aList, 2) of me –x1でソートして最小のものをリストアップ
set y2Max to contents of item 3 of first item of shellSortListDecending(aList, 3) of me –y2でソートして最大のものをリストアップ set y2Min to contents of item 3 of first item of shellSortListAscending(aList, 3) of me –y2でソートして最小のものをリストアップ
set x2Max to contents of item 4 of first item of shellSortListDecending(aList, 4) of me –x2でソートして最大のものをリストアップ set x2Min to contents of item 4 of first item of shellSortListAscending(aList, 4) of me –x2でソートして最小のものをリストアップ *)
set {origY1, origX1, origY2, origX2} to originData
set aGap to 2 –オブジェクトの配置ゆらぎに対して余裕をもって、大きめに検索エリア指定を行う set areaList to {origY1 - aGap, origX1 - aGap, y1Max + (origY2 - origY1) + aGap, origX1 + origX2 + aGap}
set resList to withinRange_Y1X1Y2X2(areaList, aList) of me set yItemNum to length of resList
–指定矩形内に含まれるデータをリストで返す on withinRange_Y1X1Y2X2(rangeList, targetList) set includedList to {} set y1 to item 1 of rangeList set x1 to item 2 of rangeList set y2 to item 3 of rangeList set x2 to item 4 of rangeList repeat with i in targetList set targY1 to item 1 of i set targX1 to item 2 of i set targY2 to item 3 of i set targX2 to item 4 of i if (x1 < targX1) and (x2 > targX2) and (y1 < targY1) and (y2 > targY2) then set the end of includedList to (contents of i) end if end repeat return includedList end withinRange_Y1X1Y2X2
–シェルソートで入れ子のリストを昇順ソート on shellSortListAscending(a, keyItem) set n to length of a set cols to {1391376, 463792, 198768, 86961, 33936, 13776, 4592, 1968, 861, 336, 112, 48, 21, 7, 3, 1} repeat with h in cols if (h ≤ (n - 1)) then repeat with i from h to (n - 1) set v to item (i + 1) of a set j to i repeat while (j ≥ h) and ((contents of item keyItem of item (j - h + 1) of a) > (item keyItem of v)) set (item (j + 1) of a) to (item (j - h + 1) of a) set j to j - h end repeat set item (j + 1) of a to v end repeat end if end repeat return a end shellSortListAscending
–シェルソートで入れ子のリストを降順ソート on shellSortListDecending(a, keyItem) set n to length of a set cols to {1391376, 463792, 198768, 86961, 33936, 13776, 4592, 1968, 861, 336, 112, 48, 21, 7, 3, 1} repeat with h in cols if (h ≤ (n - 1)) then repeat with i from h to (n - 1) set v to item (i + 1) of a set j to i repeat while (j ≥ h) and ((contents of item keyItem of item (j - h + 1) of a) < (item keyItem of v)) set (item (j + 1) of a) to (item (j - h + 1) of a) set j to j - h end repeat set item (j + 1) of a to v end repeat end if end repeat return a end shellSortListDecending
–テスト用データ。実際にはInDesignのDocument上の選択中のオブジェクトからgeometric boundsを取得した結果 on retGeometricBounds() return {{15.97, 6.0, 21.1, 10.0}, {21.1, 6.0, 26.23, 10.0}, {26.23, 6.0, 31.36, 10.0}, {31.36, 6.0, 36.49, 10.0}, {36.49, 6.0, 41.62, 10.0}, {41.62, 6.0, 46.75, 10.0}, {46.75, 6.0, 51.88, 10.0}, {51.88, 6.0, 57.01, 10.0}, {57.01, 6.0, 62.14, 10.0}, {62.14, 6.0, 67.27, 10.0}, {67.27, 6.0, 72.4, 10.0}, {72.4, 6.0, 77.53, 10.0}, {77.53, 6.0, 82.66, 10.0}, {82.66, 6.0, 87.79, 10.0}, {87.79, 6.0, 92.92, 10.0}, {92.92, 6.0, 98.05, 10.0}, {98.05, 6.0, 103.18, 10.0}, {103.18, 6.0, 108.31, 10.0}, {108.31, 6.0, 113.44, 10.0}, {113.44, 6.0, 118.57, 10.0}, {118.57, 6.0, 123.7, 10.0}, {123.7, 6.0, 128.83, 10.0}, {128.83, 6.0, 133.96, 10.0}, {133.96, 6.0, 139.09, 10.0}, {139.09, 6.0, 144.22, 10.0}, {144.22, 6.0, 149.35, 10.0}, {149.35, 6.0, 154.48, 10.0}, {154.48, 6.0, 159.61, 10.0}, {15.97, 24.35, 21.1, 28.35}, {21.1, 24.35, 26.23, 28.35}, {26.23, 24.35, 31.36, 28.35}, {31.36, 24.35, 36.49, 28.35}, {36.49, 24.35, 41.62, 28.35}, {41.62, 24.35, 46.75, 28.35}, {46.75, 24.35, 51.88, 28.35}, {51.88, 24.35, 57.01, 28.35}, {57.01, 24.35, 62.14, 28.35}, {62.14, 24.35, 67.27, 28.35}, {67.27, 24.35, 72.4, 28.35}, {72.4, 24.35, 77.53, 28.35}, {77.53, 24.35, 82.66, 28.35}, {82.66, 24.35, 87.79, 28.35}, {87.79, 24.35, 92.92, 28.35}, {92.92, 24.35, 98.05, 28.35}, {98.05, 24.35, 103.18, 28.35}, {103.18, 24.35, 108.31, 28.35}, {108.31, 24.35, 113.44, 28.35}, {113.44, 24.35, 118.57, 28.35}, {118.57, 24.35, 123.7, 28.35}, {123.7, 24.35, 128.83, 28.35}, {128.83, 24.35, 133.96, 28.35}, {133.96, 24.35, 139.09, 28.35}, {139.09, 24.35, 144.22, 28.35}, {144.22, 24.35, 149.35, 28.35}, {149.35, 24.35, 154.48, 28.35}, {154.48, 24.35, 159.61, 28.35}, {15.97, 42.7, 21.1, 46.7}, {21.1, 42.7, 26.23, 46.7}, {26.23, 42.7, 31.36, 46.7}, {31.36, 42.7, 36.49, 46.7}, {36.49, 42.7, 41.62, 46.7}, {41.62, 42.7, 46.75, 46.7}, {46.75, 42.7, 51.88, 46.7}, {51.88, 42.7, 57.01, 46.7}, {57.01, 42.7, 62.14, 46.7}, {62.14, 42.7, 67.27, 46.7}, {67.27, 42.7, 72.4, 46.7}, {72.4, 42.7, 77.53, 46.7}, {77.53, 42.7, 82.66, 46.7}, {82.66, 42.7, 87.79, 46.7}, {87.79, 42.7, 92.92, 46.7}, {92.92, 42.7, 98.05, 46.7}, {98.05, 42.7, 103.18, 46.7}, {103.18, 42.7, 108.31, 46.7}, {108.31, 42.7, 113.44, 46.7}, {113.44, 42.7, 118.57, 46.7}, {118.57, 42.7, 123.7, 46.7}, {123.7, 42.7, 128.83, 46.7}, {128.83, 42.7, 133.96, 46.7}, {133.96, 42.7, 139.09, 46.7}, {139.09, 42.7, 144.22, 46.7}, {144.22, 42.7, 149.35, 46.7}, {149.35, 42.7, 154.48, 46.7}, {154.48, 42.7, 159.61, 46.7}, {15.97, 61.05, 21.1, 65.05}, {21.1, 61.05, 26.23, 65.05}, {26.23, 61.05, 31.36, 65.05}, {31.36, 61.05, 36.49, 65.05}, {36.49, 61.05, 41.62, 65.05}, {41.62, 61.05, 46.75, 65.05}, {46.75, 61.05, 51.88, 65.05}, {51.88, 61.05, 57.01, 65.05}, {57.01, 61.05, 62.14, 65.05}, {62.14, 61.05, 67.27, 65.05}, {67.27, 61.05, 72.4, 65.05}, {72.4, 61.05, 77.53, 65.05}, {77.53, 61.05, 82.66, 65.05}, {82.66, 61.05, 87.79, 65.05}, {87.79, 61.05, 92.92, 65.05}, {92.92, 61.05, 98.05, 65.05}, {98.05, 61.05, 103.18, 65.05}, {103.18, 61.05, 108.31, 65.05}, {108.31, 61.05, 113.44, 65.05}, {113.44, 61.05, 118.57, 65.05}, {118.57, 61.05, 123.7, 65.05}, {123.7, 61.05, 128.83, 65.05}, {128.83, 61.05, 133.96, 65.05}, {133.96, 61.05, 139.09, 65.05}, {139.09, 61.05, 144.22, 65.05}, {144.22, 61.05, 149.35, 65.05}, {149.35, 61.05, 154.48, 65.05}, {154.48, 61.05, 159.61, 65.05}, {15.97, 79.4, 21.1, 83.4}, {21.1, 79.4, 26.23, 83.4}, {26.23, 79.4, 31.36, 83.4}, {31.36, 79.4, 36.49, 83.4}, {36.49, 79.4, 41.62, 83.4}, {41.62, 79.4, 46.75, 83.4}, {46.75, 79.4, 51.88, 83.4}, {51.88, 79.4, 57.01, 83.4}, {57.01, 79.4, 62.14, 83.4}, {62.14, 79.4, 67.27, 83.4}, {67.27, 79.4, 72.4, 83.4}, {72.4, 79.4, 77.53, 83.4}, {77.53, 79.4, 82.66, 83.4}, {82.66, 79.4, 87.79, 83.4}, {87.79, 79.4, 92.92, 83.4}, {92.92, 79.4, 98.05, 83.4}, {98.05, 79.4, 103.18, 83.4}, {103.18, 79.4, 108.31, 83.4}, {108.31, 79.4, 113.44, 83.4}, {113.44, 79.4, 118.57, 83.4}, {118.57, 79.4, 123.7, 83.4}, {123.7, 79.4, 128.83, 83.4}, {128.83, 79.4, 133.96, 83.4}, {133.96, 79.4, 139.09, 83.4}, {139.09, 79.4, 144.22, 83.4}, {144.22, 79.4, 149.35, 83.4}, {149.35, 79.4, 154.48, 83.4}, {154.48, 79.4, 159.61, 83.4}, {15.97, 97.75, 21.1, 101.75}, {21.1, 97.75, 26.23, 101.75}, {26.23, 97.75, 31.36, 101.75}, {31.36, 97.75, 36.49, 101.75}, {36.49, 97.75, 41.62, 101.75}, {41.62, 97.75, 46.75, 101.75}, {46.75, 97.75, 51.88, 101.75}, {51.88, 97.75, 57.01, 101.75}, {57.01, 97.75, 62.14, 101.75}, {62.14, 97.75, 67.27, 101.75}, {67.27, 97.75, 72.4, 101.75}, {72.4, 97.75, 77.53, 101.75}, {77.53, 97.75, 82.66, 101.75}, {82.66, 97.75, 87.79, 101.75}, {87.79, 97.75, 92.92, 101.75}, {92.92, 97.75, 98.05, 101.75}, {98.05, 97.75, 103.18, 101.75}, {103.18, 97.75, 108.31, 101.75}, {108.31, 97.75, 113.44, 101.75}, {113.44, 97.75, 118.57, 101.75}, {118.57, 97.75, 123.7, 101.75}, {123.7, 97.75, 128.83, 101.75}, {128.83, 97.75, 133.96, 101.75}, {133.96, 97.75, 139.09, 101.75}, {139.09, 97.75, 144.22, 101.75}, {144.22, 97.75, 149.35, 101.75}, {149.35, 97.75, 154.48, 101.75}, {154.48, 97.75, 159.61, 101.75}} end retGeometricBounds |