AppleScript: coerce – coercion of measurement units/values in quarkxpress

(*
qxp_coerce_01.applescript

Coerce the swiss army knife to convert measurement units.
*)

tell application "QuarkXPress Passport"
    tell document 1
        -- get bounds of generic box 1 of document 1.
        set {t, l, b, r} to bounds of generic box 1 as list

        -- for example t (top of bounds) would be coerced from
        -- vertical measurement ('FXVM') of QuarkXPress to a real number
        -- "8,467 mm" => 8.466644287109
        set t_as_real to coerce t to real

        -- for example l (left of bounds) would be coerced from
        -- horizontal measurement ('FXHM') of QuarkXPress to a string
        -- "20,461Â mm" => "20,461Â mm"
        set l_as_string to coerce l to string

    end tell
end tell

 

AppleScript: duplicate object in quarkxpress document

(*
qxp_duplicate_01.applescript

Duplicates an object.
*)

tell application "QuarkXPress Passport"
    -- Example 1: copy a object from layout space 1 to layout space 2
    tell project 1
        duplicate generic box 1 of layout space 1 to beginning of layout space 2
    end tell

    -- Example 2: copy a object from document 1 to document 2 
    duplicate generic box 1 of layout space 1 of project 1 to beginning of layout space 1 of project 2
end tell

 

AppleScript: make new text box in quarkxpress

(*
qxp_textbox_01.applescript

Creates a new text box

Properties are for example.
*)

tell application "QuarkXPress Passport"
    tell document 1
        make new text box at end with properties {class:text box, content:text content, box type:text box type, box shape:rectangular, first baseline minimum:ascent baseline, first baseline offset:"0 mm", runaround all sides:false, storage:"", text outset:{"0 pt", "0 pt", "0 pt", "0 pt"}, vertical justification:top justified, columns:1, gutter:"4,233 mm", name:"LOG_TEST_MODUL", shade:"20%", runaround:none runaround, color:color spec "Gelb", blend:{style:solid blend}, frame:{style:dotted line, inside trap:default, outside trap:default, gap color:null, gap opacity:"0%", gap shade:"0%", width:"6 pt", color:color spec "Magenta"}, bounds:{"0 mm", "0,269 mm", "183,132 mm", "47,269 mm"}}
        set text of last generic box to "Das ist ein kleiner Test"
        set style sheet of paragraph 1 of story 1 of last generic box to object reference of style spec "Normal"
        set character style of every text of last generic box whose it is "Das ist ein kleiner Test" to object reference of character spec "Normal"
    end tell
end tell

 

AppleScript: make new picture box in quarkxpress

(*
qxp_picturebox_01.applescript

Creates a new picture box

Properties are for example. It seems that not all properties are set properly when
a new picture box is generated.
Setting of image 1 of an picture box is some times a little bit buggy?
*)

tell application "QuarkXPress Passport"
    tell document 1
        make new picture box at end with properties {class:picture box, name:"m_bilder_TEST", content:picture content, box type:picture box type, box shape:rounded corner, bounds:{"0 mm", "48 mm", "112,818 mm", "188 mm"}, storage:"", blend:{style:solid blend}, frame:{style:sparsely dashed line, inside trap:default, outside trap:default, gap color:null, gap opacity:"0%", gap shade:"0%", width:"3 pt", color:color spec "Schwarz"}, text outset:{"0 pt", "0 pt", "6 pt", "0 pt"}, corner radius:"10 mm", shade:"20%", runaround:item runaround, color:color spec "Schwarz"}
        -- Fixing some stuff
        set properties of last generic box to {corner radius:"10 mm", bounds:{"0 mm", "48 mm", "112,818 mm", "188 mm"}}
        -- Image file path & Image Properties
        try
            set image 1 of last generic box to file ("BootHD:Users:csg:Desktop:export_preissuchmaschine.png")
            -- another way to set image 1
            --set image 1 of last generic box to ("BootHD:Users:csg:Desktop:export_preissuchmaschine.png" as alias)
            set properties of image 1 of last generic box to {actual bounds:{"-51,279 mm", "-38,459 mm", "268,111 mm", "274,461 mm"}, screen function:dot spot, offset:{"-38,459 mm", "-51,279 mm"}, scale:{"100%", "100%"}, invert runaround:false, show half tone:false, color:color spec "Schwarz"}
        end try
    end tell
end tell

 

AppleScript: make new style spec in quarkxpress

(*
qxp_stylespec_01.applescript

Creates a new text box

Properties are for example. rule above and rule below (position and indent) are not correct scriptable.
*)

tell application "QuarkXPress Passport"
    tell document 1
        if not (exists style spec "10_Hotelname") then
            make new style spec at beginning with properties {class:style spec, base style:null, character attributes:{language:3, font:"TheSans B7 Bold", shade:"60%", size:"12 pt", color:color spec "Schwarz"}, character style:null, key character:"", name:"10_Hotelname", next style:style spec "10_Hotelname", paragraph attributes:{rule above:{rule on:false}, rule below:{rule on:true, text length:Indents, position:"34%", style:solid line, width:"0,5 pt", color:color spec "0/60/100/0"}, left indent:"7 mm", grid lock:false, leading:"16 pt", justification:left justified, relative leading:false}}
        end if
    end tell
end tell

 

AppleScript: make new character spec in quarkxpress

(*
qxp_characterspec_01.applescript

Creates a new text box

Properties are for example.
*)

tell application "QuarkXPress Passport"
    tell document 1
        if not (exists character spec "10_Hotelname") then
            make new character spec at beginning with properties {class:character spec, base style:null, key character:"", language:3, font:"TheSans B7 Bold", name:"10_Hotelname", shade:"60%", size:"12 pt", color:color spec "Schwarz"}
        end if
    end tell
end tell

 

AppleScript: make new color spec in quarkxpress

(*
qxp_colorspec_01.applescript

Creates a new colorspec

Properties are for example. For more details see the dictionary.
*)

tell application "QuarkXPress Passport"
    tell document 1
        if not (exists color spec "0/60/100/0") then
            make new color spec at beginning with properties {class:color spec, color type:CMYK type, angle:"45", CMYK color value:{0, 39321, 65535, 0}, name:"0/60/100/0", separation:true}
        end if
    end tell
end tell