Hello,
We want to find text frames that has object style "X" in all pages. So far, we wrote this.
[code]
function paragraphByNesneStilWp(stil) {
var tests = [], i, j, it, p, buldu, d = myDoc;
for(i = 0; i < d.pages.length; ++i) {
p = d.pages.item(i);
if(p && p.isValid) {
pi = p.textFrames;
buldu = false;
for(j = 0; j < pi.length; ++j) {
it = pi[j];
if(it && it.appliedObjectStyle == stil) {
buldu = true;
tests.push({pr: it, sn: i});
break;
}
}
if(!buldu) {
pi = p.masterPageItems;
for(j = 0; j < pi.length; ++j) {
it = pi[j];
try {
if(it && it.appliedObjectStyle == stil) {
tests.push({pr: it.override(p), sn: i});
break;
}
} catch(e){}
}
}
}
}
return tests;
}
[/code]
The input parameter of this function "stil" is the object style. We are using this function like this.
[code]
function os(a) {
var x, i;
for(i = 0; i < a.length; ++i) {
if(i == a.length - 1) {
x = (x ? x : app.activeDocument).objectStyles.item(a[i]);
if(!x || !x.isValid) return null;
} else {
x = (x ? x : app.activeDocument).objectStyleGroups.itemByName(a[i]);
if(!x || !x.isValid) return null;
}
}
return x.isValid ? x : null;
}
var stil = os(["TEST", "TEST 1"]);
var questions = paragraphByNesneStilWp(stil);
alert("There is " + questions.length + " question in this document");
[/code]
This function returns all of the textframes in all pages that object style is stil (and if it included in the master, it also overrides it).
So far it's working great (like everyone at here ) except it does not count the textframe when it is groupped with another object (the style is applied the textframe not the group itself).
Is there anybody that can help me modifying this script? so it can count the groupped ones.
Thank you,
Burak