in

Quark Forums

Quark 7.31 and Leopard with Place picture name script

Last post 08-29-2008 2:11 PM by rudolphdesign. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 08-29-2008 2:11 PM

    Quark 7.31 and Leopard with Place picture name script

    Hello, I cannot get this script to work in leopard. It workd fine in tiger any suggestions?

    This script was extremely useful as it places all picture names in an entire multi-page document under said picture.

    Great for checking your work and I reccommend people with tiger pick this up and use it. I cannot get it to work in leopard to save my life though! Anny suggestions? 

    Here is the script in question.

     

    property createLabel : true

    -- inlineLabel = true is placing the label within the area of the picture box
    property inlineLabel : true

    property createCropMarks : false

    -- some properties for crop marks
    property cropOffset : "1 mm"
    property cropLength : "3 mm"
    property cropWidth : "0.1 mm"
    property cropColor : "Registration"

    -- some properties for label box
    property labelOffset : "1 mm"
    property labelFontSize : "6 mm"
    -- if labelFontName is "", then fontname will not be set or modified
    property labelFontName : ""

    -- property labelBackgroundColor : null
    property labelBackgroundColor : "White"
    property labelFrameWidth : "0"

    tell application "QuarkXPress"
        activate
        do script {createCorpmarksAndLabel}
        do updates
    end tell
    beep 2

    script createCorpmarksAndLabel
        tell application "QuarkXPress"
           
            -- add what ever should be appended to the image file's filename
            set imageNameAddOn to ""
           
            set myDefaultBoxHeight to labelFontSize
           
            -- check if there is a document open, exit otherwise
            if not (exists (document 1)) then
                display dialog "No document open, exit!" buttons {"OK"} default button "OK"
                return
            end if
           
            if masterdoc of document 1 is true then
                display dialog "This script doesn't work on master pages, exit!" buttons {"OK"} default button "OK"
                return
            end if
           
            -- ask user what to do
            display dialog "Do you want to add Labels/Crop Marks or remove existing ones?" buttons {"Add", "Remove", "Cancel"} default button "Cancel"
            set myResult to result
           
            if (button returned of myResult is "Cancel") then
                return
            end if
            if (button returned of myResult = "Remove") then
                -- remove crop box and name box
                try
                    delete (every generic box of document 1 whose name is "CROPITEM")
                end try
                return
            else
                -- add crop box and name box
                -- first check if there are any picture boxes in the document
                if not (exists (every picture box of document 1 whose anchored is false)) then
                    return
                end if
               
                -- save current coord state and change it to spread coords
                tell document 1
                    set currentCoordinate to get item spread coords
                    set currentPageRulerOrigin to get page rule origin
                    set currentSpreadRuleOrigin to get spread rule origin
                   
                    set item spread coords to true
                    set spread rule origin to {0, 0}
                end tell
               
                set mySpreadCount to count spread of document 1
                repeat with currentSpread from 1 to mySpreadCount
                    set myPictureBoxIDs to get (uniqueID of every picture box of spread currentSpread of document 1 whose (anchored is false))
                    set myPictureBoxHoldingImagesIDs to {}
                   
                    -- loop through the list of picture boxes and find out to which crop marks and label can be created
                    repeat with currentID in myPictureBoxIDs
                        tell generic box id currentID of spread currentSpread of document 1
                            if file path of image 1 is not null and rotation as real is 0 and skew as real is 0 then
                                set myPictureBoxHoldingImagesIDs to myPictureBoxHoldingImagesIDs & {currentID as number}
                            end if
                        end tell
                    end repeat
                   
                    -- now we have a list of uniqueIDs which hold an image
                    repeat with currentID in myPictureBoxHoldingImagesIDs
                        -- create cropmarks
                        set myName to "CROPITEM"
                        set myBounds to bounds of generic box id currentID of spread currentSpread of document 1 as list
                       
                        -- use text here to avoid problem with different measurement units
                        set myBoxX1 to (item 2 of myBounds) as text
                        set myBoxY1 to (item 1 of myBounds) as text
                        set myBoxX2 to (item 4 of myBounds) as text
                        set myBoxY2 to (item 3 of myBounds) as text
                       
                       
                        if createCropMarks then
                            tell spread currentSpread of document 1
                               
                                -- calculate coordinates for 8 lines
                               
                                -- cropTopLeftHorizontal
                                set x1 to myBoxX1 & "-" & cropLength & "-" & cropOffset
                                set y1 to myBoxY1
                                set x2 to myBoxX1 & "-" & cropOffset
                                set y2 to myBoxY1
                                make line box at before generic box id currentID with properties {left point:{y1, x1}, right point:{y2, x2}, width:cropWidth, color:cropColor, box shape:orthogonal line, name:myName}
                               
                                -- cropTopLeftVertical
                                set x1 to myBoxX1
                                set y1 to myBoxY1 & "-" & cropLength & "-" & cropOffset
                                set x2 to myBoxX1
                                set y2 to myBoxY1 & "-" & cropOffset
                                make line box at before generic box id currentID with properties {left point:{y1, x1}, right point:{y2, x2}, width:cropWidth, color:cropColor, box shape:orthogonal line, name:myName}
                               
                                -- cropTopRightHorizontal
                                set x1 to myBoxX2 & "+" & cropOffset
                                set y1 to myBoxY1
                                set x2 to myBoxX2 & "+" & cropOffset & "+" & cropLength
                                set y2 to myBoxY1
                                make line box at before generic box id currentID with properties {left point:{y1, x1}, right point:{y2, x2}, width:cropWidth, color:cropColor, box shape:orthogonal line, name:myName}
                               
                                -- cropTopRightVertical
                                set x1 to myBoxX2
                                set y1 to myBoxY1 & "-" & cropLength & "-" & cropOffset
                                set x2 to myBoxX2
                                set y2 to myBoxY1 & "-" & cropOffset
                                make line box at before generic box id currentID with properties {left point:{y1, x1}, right point:{y2, x2}, width:cropWidth, color:cropColor, box shape:orthogonal line, name:myName}
                               
                                -- cropBottomLeftHorizontal
                                set x1 to myBoxX1 & "-" & cropLength & "-" & cropOffset
                                set y1 to myBoxY2
                                set x2 to myBoxX1 & "-" & cropOffset
                                set y2 to myBoxY2
                                make line box at before generic box id currentID with properties {left point:{y1, x1}, right point:{y2, x2}, width:cropWidth, color:cropColor, box shape:orthogonal line, name:myName}
                               
                                -- cropBottomLeftVertical
                                set x1 to myBoxX1
                                set y1 to myBoxY2 & "+" & cropOffset
                                set x2 to myBoxX1
                                set y2 to myBoxY2 & "+" & cropOffset & "+" & cropLength
                                make line box at before generic box id currentID with properties {left point:{y1, x1}, right point:{y2, x2}, width:cropWidth, color:cropColor, box shape:orthogonal line, name:myName}
                               
                                -- cropBottomRightHorizontal
                                set x1 to myBoxX2 & "+" & cropOffset
                                set y1 to myBoxY2
                                set x2 to myBoxX2 & "+" & cropOffset & "+" & cropLength
                                set y2 to myBoxY2
                                make line box at before generic box id currentID with properties {left point:{y1, x1}, right point:{y2, x2}, width:cropWidth, color:cropColor, box shape:orthogonal line, name:myName}
                               
                                -- cropBottomRightVertical
                                set x1 to myBoxX2
                                set y1 to myBoxY2 & "+" & cropOffset
                                set x2 to myBoxX2
                                set y2 to myBoxY2 & "+" & cropOffset & "+" & cropLength
                                make line box at before generic box id currentID with properties {left point:{y1, x1}, right point:{y2, x2}, width:cropWidth, color:cropColor, box shape:orthogonal line, name:myName}
                            end tell
                        end if
                       
                        if createLabel then
                            tell generic box id currentID of spread currentSpread of document 1
                               
                                -- get filename of image
                                set myFilePath to get file path of image 1
                                if class of myFilePath is constant then
                                    set myImageName to "Embedded Image"
                                else
                                    -- set myImageName to name of (info for myFilePath)
                                    set myFilePath to myFilePath as text
                                    set myImageName to myFilePath
                                   
                                    -- this part extracts the filename out of the file path:
                                   
                                    set currenDilimiter to text item delimiters of AppleScript
                                    set text item delimiters of AppleScript to {":"}
                                    set myImageName to last text item of myFilePath
                                    set text item delimiters of AppleScript to currenDilimiter
                                end if
                                set myImageName to myImageName & imageNameAddOn
                                if inlineLabel then
                                    set x1 to myBoxX1 & "+" & labelOffset
                                    set y1 to myBoxY2 & "-" & labelOffset & "-" & myDefaultBoxHeight & "-" & labelFrameWidth & "-" & labelFrameWidth
                                    set x2 to myBoxX2 & "-" & labelOffset
                                    set y2 to myBoxY2 & "-" & labelOffset
                                else
                                    set x1 to myBoxX1 & "+" & labelOffset
                                    set y1 to myBoxY2 & "+" & labelOffset
                                    set x2 to myBoxX2 & "-" & labelOffset
                                    set y2 to myBoxY2 & "+" & labelOffset & "+" & myDefaultBoxHeight & "+" & labelFrameWidth & "+" & labelFrameWidth
                                end if
                               
                                set myLabelBox to make new text box at before it with properties {bounds:{y1, x1, y2, x2}, runaround:none runaround, vertical justification:top justified, name:myName, color:labelBackgroundColor, frame:{width:labelFrameWidth, color:cropColor}}
                                set text of myLabelBox to myImageName
                                set size of every text of myLabelBox to labelFontSize
                                if labelFontName is not "" then
                                    try
                                        set font of every text of myLabelBox to labelFontName
                                    end try
                                end if
                            end tell
                        end if
                    end repeat
                end repeat
               
                -- some house keeping
                tell document 1
                    set item spread coords to currentCoordinate
                    set page rule origin to currentPageRulerOrigin
                    set spread rule origin to currentSpreadRuleOrigin
                end tell
            end if
            return
        end tell
    end script

Page 1 of 1 (1 items)
Powered by Community Server (Commercial Edition), by Telligent Systems