0

スクリプト ドロップレットを完成させて、スクリプトにドロップして一覧表示する複数のインデザイン ドキュメントからすべての使用済みスウォッチを取得する作業を行っています。これは、使用済みのすべてのスウォッチを単一のファイルから配置するために作成したスクリプトから適応しています。

私は基本を理解していますが、2 つの問題に遭遇し、答えが見つかりません。

問題 1: 「swatchCount < 2 まで繰り返す」という行を追加する必要がありますが、これは繰り返しの中に繰り返しを広告します。うまくいきません。

問題 2: (最大の問題) 「colorList」では、各ドキュメントの色を 1 つのリストに追加する必要があります。繰り返し使用しているため、最後に処理されたファイルの色のみがリストされています。リストに各ファイルの色を保存してから、すべてをリストするにはどうすればよいですか?

私が壁にぶつかったのを助けていただければ幸いです。

on open these_items

    repeat with i from 1 to the count of these_items
        set this_item to item i of these_items
        set the item_info to info for this_item
        set this_item to POSIX path of this_item

        tell application "Adobe InDesign CC"
            open this_item

            tell active document
                delete unused swatches
                set allSwatches to every swatch
            end tell
            set swatchCount to count of allSwatches
            set colorList to ""
            -- repeat until swatchCount < 2
            set thisSwatch to item swatchCount of allSwatches

            try
                set swatchProps to type of thisSwatch
                set swatchProps to "Gradient"
            on error
                set swatchProps to "Color"
            end try

            if swatchProps = "Color" then

                set swatchName to name of thisSwatch as string
                set swatchType to model of thisSwatch as string
                set swatchSpace to space of thisSwatch as string
                set swatchColor to color value of thisSwatch

                if swatchType contains "spot" then
                    set swatchType to "Spot"
                else
                    if swatchType contains "prss" then
                        set swatchType to "Process"
                    end if
                end if

                if swatchSpace contains "RGB" then
                    set rrr to ((item 1 of swatchColor) as integer)
                    set ggg to ((item 2 of swatchColor) as integer)
                    set bbb to ((item 3 of swatchColor) as integer)
                    set swatchMix to (" value: R-" & rrr & "  G-" & ggg & "  B-" & bbb) as string

                    if swatchName does not contain "registration" then
                        set swatchItem to "Name: " & swatchName & swatchMix & " space: RGB" & " type: " & swatchType & return
                    else
                        set swatchItem to ""
                    end if
                else
                    if swatchSpace contains "CMYK" then
                        set ccc to ((item 1 of swatchColor) as integer)
                        set mmm to ((item 2 of swatchColor) as integer)
                        set yyy to ((item 3 of swatchColor) as integer)
                        set kkk to ((item 4 of swatchColor) as integer)
                        set swatchMix to (" value: C-" & ccc & "  M-" & mmm & "  Y-" & yyy & "  K-" & kkk) as string

                        if swatchName does not contain "registration" then
                            set swatchItem to "Name: " & swatchName & swatchMix & " space:CMYK" & " type: " & swatchType & return
                        else
                            set swatchItem to ""
                        end if
                    else
                        if swatchSpace contains "LAB" then
                            set lll to ((item 1 of swatchColor) as integer)
                            set aaa to ((item 2 of swatchColor) as integer)
                            set bbb to ((item 3 of swatchColor) as integer)

                            set swatchMix to (" value: L-" & lll & "  A-" & aaa & "  B-" & bbb) as string

                            if swatchName does not contain "registration" then
                                set swatchItem to "Name: " & swatchName & swatchMix & " space: LAB" & " type: " & swatchType & return
                            else
                                set swatchItem to ""
                            end if
                        end if
                    end if
                end if

                set colorList to colorList & swatchItem
            end if

            tell active document to close saving no
            set swatchCount to swatchCount - 1

            --end repeat
        end tell

    end repeat



    set dragged_items to these_items as string
    set old_delimiters to AppleScript's text item delimiters
    set AppleScript's text item delimiters to {":"}

    set theClientName to text item 2 of dragged_items
    set theFileName to text item 5 of dragged_items

    set AppleScript's text item delimiters to old_delimiters

    set theOrderNumber to text 1 through 5 of theFileName
    set headerInfo to "Client: " & theClientName & "        Order # " & theOrderNumber & "      File: " & theFileName
    tell application "Adobe InDesign CC"
        tell view preferences
            set horizontal measurement units to inches
            set vertical measurement units to inches
        end tell
        make new document with properties {document preferences:{page width:8.5, page height:11}}
        tell view preferences
            set horizontal measurement units to inches
            set vertical measurement units to inches
        end tell
        tell active document
            set zero point to {0, 0}
            set properties of guide preferences to {guides shown:false}
            set properties of text preferences to {show invisibles:false}
            set properties of view preferences to {ruler origin:page origin, horizontal measurement units:inches, show frame edges:false, show rulers:true, vertical measurement units:inches}
            tell layout window 1
                zoom given fit page
                set properties to {view display setting:typical, transform reference point:top left anchor}
            end tell

            make new text frame with properties {geometric bounds:{0.5, 0.5, 0.75, 8.0}, contents:headerInfo, color:"None"}

            set paragraphCount to count of paragraphs of colorList
            repeat until paragraphCount > 19
                set colorList to colorList & "name: _________________________" & "  value: ____________________" & "    space: ______" & "  type: _________" & return
                set paragraphCount to count of paragraphs of colorList
            end repeat

            make new text frame with properties {geometric bounds:{4.5, 0.5, 20.0, 8.0}, contents:colorList, color:"None"}

            tell text frame 1
                tell every text to set point size to 10
                tell every paragraph
                    make tab stop with properties {alignment:left align, position:2.875}
                    make tab stop with properties {alignment:left align, position:5.125}
                    make tab stop with properties {alignment:left align, position:6.375}
                end tell
                set geometric bounds to {1.0, 0.5, 11, 8.0}
            end tell
        end tell
    end tell

end open

on run
    --  Handle the case where the script is launched without any dropped files
    open (choose file with multiple selections allowed)
end run

「Darrick Herwehe」が提案した変更を追加しましたが、別の部分でエラーが発生しています。

ドキュメント ID 30 のカラー ID 344 の名前を取得できません
--アプリケーション「Adobe InDesign CC」のドキュメント ID 29 のカラー ID 344 の名前--

これを参照して取得する: swatchName を thisSwatch の名前に設定する これらのアイテム を開く colorList を "" に設定する swatchItem を "" に設定する

repeat with i from 1 to the count of these_items

    --Get swatches from document start
    set this_item to item i of these_items
    set the item_info to info for this_item
    set this_item to POSIX path of this_item

    tell application "Adobe InDesign CC"
        open this_item

        tell active document
            delete unused swatches
            set allSwatches to every swatch
        end tell
        set swatchCount to count of allSwatches

        repeat until swatchCount < 2

            repeat with j from 1 to (count allSwatches)
                set thisSwatch to item swatchCount of allSwatches

                try
                    set swatchProps to type of thisSwatch
                    set swatchProps to "Gradient"
                on error
                    set swatchProps to "Color"
                end try

                if swatchProps = "Color" then
                                            set swatchName to name of thisSwatch
                    set swatchType to model of thisSwatch
                    set swatchSpace to space of thisSwatch
                    set swatchColor to color value of thisSwatch

                    if swatchType contains "spot" then
                        set swatchType to "Spot"
                    else
                        if swatchType contains "prss" then
                            set swatchType to "Process"
                        end if
                    end if

                    if swatchSpace contains "RGB" then
                        set rrr to ((item 1 of swatchColor) as integer)
                        set ggg to ((item 2 of swatchColor) as integer)
                        set bbb to ((item 3 of swatchColor) as integer)
                        set swatchMix to (" value: R-" & rrr & "  G-" & ggg & "  B-" & bbb) as string

                        if swatchName does not contain "registration" then
                            set swatchItem to "Name: " & swatchName & swatchMix & " space: RGB" & " type: " & swatchType & return
                        else
                            set swatchItem to ""
                        end if
                    else
                        if swatchSpace contains "CMYK" then
                            set ccc to ((item 1 of swatchColor) as integer)
                            set mmm to ((item 2 of swatchColor) as integer)
                            set yyy to ((item 3 of swatchColor) as integer)
                            set kkk to ((item 4 of swatchColor) as integer)
                            set swatchMix to (" value: C-" & ccc & "  M-" & mmm & "  Y-" & yyy & "  K-" & kkk) as string

                            if swatchName does not contain "registration" then
                                set swatchItem to "Name: " & swatchName & swatchMix & " space:CMYK" & " type: " & swatchType & return
                            else
                                set swatchItem to ""
                            end if
                        else
                            if swatchSpace contains "LAB" then
                                set lll to ((item 1 of swatchColor) as integer)
                                set aaa to ((item 2 of swatchColor) as integer)
                                set bbb to ((item 3 of swatchColor) as integer)

                                set swatchMix to (" value: L-" & lll & "  A-" & aaa & "  B-" & bbb) as string

                                if swatchName does not contain "registration" then
                                    set swatchItem to "Name: " & swatchName & swatchMix & " space: LAB" & " type: " & swatchType & return
                                else
                                    set swatchItem to ""
                                end if
                            end if
                        end if
                    end if
                    tell active document to close saving no
                    set colorList to colorList & swatchItem
                end if


                set swatchCount to swatchCount - 1

            end repeat
        end repeat
    end tell

end repeat



set dragged_items to these_items as string
set old_delimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}

set theClientName to text item 2 of dragged_items
set theFileName to text item 5 of dragged_items

set AppleScript's text item delimiters to old_delimiters

set theOrderNumber to text 1 through 5 of theFileName
set headerInfo to "Client: " & theClientName & "        Order # " & theOrderNumber & "      File: " & theFileName
tell application "Adobe InDesign CC"
    tell view preferences
        set horizontal measurement units to inches
        set vertical measurement units to inches
    end tell
    make new document with properties {document preferences:{page width:8.5, page height:11}}
    tell view preferences
        set horizontal measurement units to inches
        set vertical measurement units to inches
    end tell
    tell active document
        set zero point to {0, 0}
        set properties of guide preferences to {guides shown:false}
        set properties of text preferences to {show invisibles:false}
        set properties of view preferences to {ruler origin:page origin, horizontal measurement units:inches, show frame edges:false, show rulers:true, vertical measurement units:inches}
        tell layout window 1
            zoom given fit page
            set properties to {view display setting:typical, transform reference point:top left anchor}
        end tell

        make new text frame with properties {geometric bounds:{0.5, 0.5, 0.75, 8.0}, contents:headerInfo, color:"None"}

        set paragraphCount to count of paragraphs of colorList
        repeat until paragraphCount > 19
            set colorList to colorList & "name: _________________________" & "  value: ____________________" & "    space: ______" & "  type: _________" & return
            set paragraphCount to count of paragraphs of colorList
        end repeat

        make new text frame with properties {geometric bounds:{4.5, 0.5, 20.0, 8.0}, contents:colorList, color:"None"}

        tell text frame 1
            tell every text to set point size to 10
            tell every paragraph
                make tab stop with properties {alignment:left align, position:2.875}
                make tab stop with properties {alignment:left align, position:5.125}
                make tab stop with properties {alignment:left align, position:6.375}
            end tell
            set geometric bounds to {1.0, 0.5, 11, 8.0}
        end tell
    end tell
end tell

エンドオープン

on run -- ドロップされたファイルを開かずにスクリプトが起動された場合を処理します (複数選択が許可されたファイルを選択します) end run

何か洞察があれば、私はそれを高く評価します。もう一度ありがとうマット

4

1 に答える 1

2

繰り返しループをネストできます。それは問題ではありません、それはいつも行われています。最初の繰り返しループとは異なる反復変数を定義するだけです。あなたの場合、私はj.

すべての色を 1 つのリストにまとめるにはcolorList、最初の繰り返しループの外で定義する必要があります。そうすれば、各反復中に上書きされません。

その概要は次のとおりです。

on open these_items
    set colorList to ""
    repeat with i from 1 to the count of these_items
        -- [ Get swatches from the document ]
        repeat with j from 1 to (count allSwatches)
            -- [ Process your swatches ]
            set colorList to colorList & swatchItem
        end repeat
    end repeat
end open
于 2013-10-17T13:05:38.403 に答える