0

I've this problem.
In my document i want to "scan" every text box and search a specific first letter with specific applied font and applied size (etcetera...)
If i find it, copy entire story of text item and past it in another document
If i don't find, search another type of specific first letter...
If i find it, copy entire story of text item and past it in another document
If i don't find, search another type of specific first letter...
If i find it, copy entire story of text item and past it in another document

That for all page of my doc

tell application (CS6)
-- bla bla bla   
if applied font of character 1 of characters of texts of object reference of text frame 1 of text frames is ("Taz" & tab & "Regular") then

or

tell application (CS6)
set Titoli to {applied font:"Taz", point size:{15, 16, 17, 18, 19, 20}}
-- bla bla bla   
if applied font of character 1 of characters of texts of object reference of text frame 1 of text frames is in Titoli then ...

but it didn't work... :-(

My applescript's knowledgement are worse than my bad english ... sorry.
Thanks in advance for every suggestion

tell application "Adobe InDesign CS6"
-- VERIFICA E DEFINIZIONE DOCUMENTO
try
    set Tedesco to active document
on error
    display dialog "Nessun documento aperto." buttons {"Annulla"} default button "Annulla" with icon 0
end try
set Titoli to {applied font:"Taz", point size:{15, 16, 17, 18, 19, 20}}
set Testo to {applied font:"Taz", fill color:"Black", point size:8}
set Didascalie to {applied font:"TazCd", fill color:"Black", point size:7.5} -- dev'essere "da 5 a 7.5"
set Sottotitoli to {applied font:"Taz" & tab & "Semibold", fill color:"White", point size:14}
tell Tedesco
    set PagineTotali to count pages of Tedesco
    repeat with PaginaCorrente from 1 to PagineTotali -- ripeti per tutte le pagine del documento
        set locked of every text frame to false -- sblocca tutti i box di testo
        set allTextBoxes to text frames of page (PaginaCorrente) -- seleziona tutti i box di testo della pagina
        repeat with textboxnum from 1 to count allTextBoxes
            set currentTextBox to item textboxnum of allTextBoxes
            set myTextFrame to currentTextBox -- definisce myTextFrame il testo contenuto nel frame 1 della mia pagina
            tell parent story of myTextFrame -- chiama tutto il contenuto di myTextFrame
                set PrimoCarattere to object reference of text from character 1 to character 1 of paragraph 1 -- seleziona solo il primo paragrafo
                tell PrimoCarattere -- chiama il testo selezionato
                    -- if label of properties of myTextFrame is not equal to "GoToTheNext"
                    if properties of every character of every text of ParagrafoUno is in Didascalie then
                        display dialog ("Didascalia")
                        set label of properties of myTextFrame to "GoToTheNext"
                    end if
                end tell
                -- set stileparagrafo to name of applied paragraph style of TestoTrovato -- definisce "stileparagrafo" il nome dello stile di paragrafo applicato al testo trovato
                -- set stilecarattere to name of applied character style of TestoTrovato -- definisce "stilecarattere" il nome dello stile di carattere applicato al testo trovato
                -- set corpo to point size of TestoTrovato -- definisce "corpo" la grandezza del corpo espressa in punti applicata al testo trovato
            end tell
        end repeat
    end repeat
end tell
end tell
armamichi
  • 21
  • 1
  • 4

1 Answers1

0

There is no need to loop through the text boxes: you can simply loop through the stories in the document.

Unfortunately, my skills in Applescript are nil, but here is how to do it in Javascript:

var myDocument = app.activeDocument;

for(myCounter = 0; myCounter < myDocument.stories.length; myCounter++){
    if(myDocument.stories.item(myCounter).characters.item(0).appliedFont.fontFamily=='Arial' && myDocument.stories.item(myCounter).characters.item(0).appliedFont.fontStyleName == 'Regular'){
        //copy paste the story here
        var newDoc = app.documents.add();
        var newTextFrame = newDoc.pages.item(0).textFrames.add();  
        newTextFrame.geometricBounds = [1, 1, 5, 5];

        myCopy =myDocument.stories.item(myCounter).texts[0].duplicate(LocationOptions.AFTER,newTextFrame.insertionPoints[0])
        }
}

Hopefully that can put you on the right path

cybernetic.nomad
  • 6,100
  • 3
  • 18
  • 31