Recent Posts

Pages: 1 2 [3] 4 5 6 7 ... 10
21
Quark XPress scripting / Re: Duplicating a Picture Box in Quark
« Last post by Jean-Marie Schwartz on October 04, 2016, 02:31:46 AM »
Hi! Glad it works :-)

As for the content, I don't really get what you mean. Are you trying to keep the picture in place while moving one of the edges? (Like taking one handle of the middle of the box and go inside of the box?) If so, you need to subtract 0.08 from the image positon as well. Are you with me?

As for the locking part, here is a piece of code Matthias or someone else at Quark posted here (as far as I remember). Mind the word item (as you code) might be too wide for your requirements.

Code: [Select]
tell application "QuarkXPress9"
activate
tell document 1
try
set locked of (every generic box whose locked is true) to false

set format lock of (every image whose format lock is true) to false
set content lock of (every image whose content lock is true) to false

set format lock of (every story whose format lock is true) to false
set content lock of (every story whose content lock is true) to false
end try
end tell
end tell
beep 2
22
Quark XPress scripting / Re: Duplicating a Picture Box in Quark
« Last post by mbornbach on October 03, 2016, 11:44:44 AM »
Thanks so much! That really helped. :)

The duplicating part works great. I'm having an issue once I try to resize the duplicated picture box. The image has a tendency to want to move with the picture box.
I tried setting the content lock and format lock for the image to true. Despite being locked, the image still moves. Is there another setting I hadn't thought of that would change it so I can resize the picture box without the image moving?

Code: [Select]
-----------------------------------------------------------------------------------------	

--CHOOSING THE FILES TO PROCESS
tell application "Finder"
set myFolder to choose folder with prompt "Select a folder"
set droppedFiles to (every file of folder myFolder whose name extension contains "qx") as alias list
end tell

-----------------------------------------------------------------------------------------


-----------------------------------------------------------------------------------------

--DUPLICATING THE PICTURE BOXES, RESIZING THE PICTURE BOXES & ADDING A DROP SHADOW TO EACH PICTURE BOX

tell application "QuarkXPress"
activate

repeat with afile in droppedFiles
open afile as alias

tell document 1

--The fancy part that adds a drop shadow to images in the document only once
set pictureBoxes to every picture box
repeat with i from (number of pictureBoxes) to 1 by -1
set pictureBox to item i of pictureBoxes


--Duplicating the picture box
set duplicateBox to duplicate pictureBox to after pictureBox


--Trying to lock the image
if content lock of image 1 of pictureBox is false then set content lock of image 1 of pictureBox to true
if format lock of image 1 of pictureBox is false then set format lock of image 1 of pictureBox to true

display dialog "Content lock: " & content lock of image 1 of pictureBox as string
display dialog "Format lock: " & format lock of image 1 of pictureBox as string


--Getting the bounds (coordinates) of the picture box
set y1 to coerce (item 1 of (bounds of pictureBox as list)) to real
set x1 to coerce (item 2 of (bounds of pictureBox as list)) to real
set y2 to coerce (item 3 of (bounds of pictureBox as list)) to real
set x2 to coerce (item 4 of (bounds of pictureBox as list)) to real


--Moving the top of the box down so it is only 0.08" high but the other coordinates are the same as the original box that was duplicated
set new_y1 to y2 - 0.08 as number
set bounds of duplicateBox to {new_y1, x1, y2, x2}


--Adding the drop shadow to the duplicated box
select duplicateBox
tell application "System Events" to key code 97 using {command down} -->Pressing Command F6 to activate the drop shadow item style

set selection to null

end repeat

-----------------------------------------------------------------------------------------



-----------------------------------------------------------------------------------------

--UNLOCKING PAGE ITEMS THAT THE SCRIPT LOCKED
try
set format lock of every item to false
set content lock of every item to false
set locked of every item to false
end try


-----------------------------------------------------------------------------------------



-----------------------------------------------------------------------------------------

--SAVING & CLOSING THE DOCUMENTS

close saving yes

---------------------------------------------------------------


end tell --end of tell document 1 block
end repeat --end of first repeat loop
end tell --end of tell Quark block

--------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------
23
Quark XPress scripting / Re: Duplicating a Picture Box in Quark
« Last post by Jean-Marie Schwartz on September 27, 2016, 07:09:53 AM »
Hi! The problem is when you duplicate a box at after another one, it takes the source box' number and add 1. So duplicating box #1 results in a new box becoming box #2; cycling through your results (pictureBoxes), will then take box #2 which is the one you just created (duplicated), so box #1's duplicate. And so on. You end up with as many copies of the #1. Does it make sense to you?
So the idea is to take the list in reverse (so duplicating the last item won't interfere with the rest of the script) which can be done like this:
repeat with i from (number of pictureBoxes) to 1 by -1

HTH.
24
Quark XPress scripting / Duplicating a Picture Box in Quark
« Last post by mbornbach on September 26, 2016, 10:54:08 AM »
I figured out that this basic part was the thing messing up my more complicated script. If I have 9 picture boxes in Quark, this script is duplicating picture box 1 nine times instead of duplicating all 9 boxes just one time each. Any help I could get with why this isn't working right would be awesome. :)

Code: [Select]
on open of droppedFiles --> This is the line of code that begins a droplet. 
   with timeout of 900 seconds -->The script will try for 15 minutes before timing out. Default is 2 minutes, which is way too little.
       
       
       
       tell application "QuarkXPress"
           activate
           
           repeat with afile in droppedFiles
               open afile
               
               
               
               tell document 1
                   
                   set pictureBoxes to every picture box
                   
                   repeat with i from 1 to number of pictureBoxes
                       set pictureBox to item i of pictureBoxes
                       set duplicateBox to duplicate pictureBox to after pictureBox
                   end repeat
                   
                   close saving yes
                   
                   
               end tell --end of tell document 1 block
           end repeat --end of first repeat loop
       end tell --end of tell Quark block
   end timeout
end open --> This is the line of code that ends a droplet.
25
Adobe InDesign scripting / Re: Locking images that are in the document multiple times
« Last post by mbornbach on September 23, 2016, 07:22:48 PM »
I have this working now, I should post the solution when I have the script handy and remember.
26
Quark XPress scripting / Adding Drop Shadows in Quark
« Last post by mbornbach on September 06, 2016, 08:56:10 AM »
I found a way to add drop shadows in Quark using AppleScript. However, I am struggling to get it to add drop shadows only to the images that don't already have one. The script is supposed to duplicate each image that is only in the document once, add a drop shadow to the duplicate image and resize the duplicate image to only .08 inches tall. The list of graphics that are in the document more than once appears to work correctly. I must be doing something wrong in the part after that. If anyone could help me figure out what I need to change, it would be greatly appreciated.


Code: [Select]
on open of droppedFiles --> This is the line of code that begins a droplet. 
with timeout of 900 seconds -->The script will try for 15 minutes before timing out. Default is 2 minutes, which is way too little.


-----------------------------------------------------------------------------------------
--BEGINNING REPEAT LOOP AND OPENING FILE
-----------------------------------------------------------------------------------------

repeat with afile in droppedFiles

tell application "QuarkXPress"
activate
open afile

-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------



-----------------------------------------------------------------------------------------
--UNLOCKING PAGE ITEMS JUST IN CASE SOMETHING WE WANT UNLOCKED WAS LOCKED
-----------------------------------------------------------------------------------------

tell document 1

set vertical measure to inches
set horizontal measure to inches

try
set format lock of every item to false
set content lock of every item to false
end try

-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------




-----------------------------------------------------------------------------------------
--BUILDING A LIST OF THE GRAPHICS THAT ARE IN THE DOCUMENT MORE THAN ONCE
-----------------------------------------------------------------------------------------

set originalList to {}

--Looping through every graphic to build a list that contains the name of every link
set theBoxes to every picture box
repeat with abox in theBoxes
set thepath to file path of image 1 of abox as string
set originalList to originalList & thepath
end repeat
--returns {AG654321.tif, AG123456.tif, AG123456.tif}

--------------------------

--Building two lists of every link that has at least 2 copies in the document
set list1 to {}
--display dialog aLinkName & "-" & matchCount
repeat with x from 1 to count of items of originalList
set n to item x of originalList
--if n is in list2 and n is not in doubleImageList then set end of doubleImageList to n
set matchCount to my count_matches(originalList, n)
if matchCount is greater than 1 then
set list1 to list1 & n
end if
end repeat
--returns {AG123456.tif, AG123456.tif}

set list2 to {}
repeat with x from 1 to count of items of originalList
set n to item x of originalList
set matchCount to my count_matches(originalList, n)
if matchCount is greater than 1 then
set list2 to list2 & n
end if
end repeat
--returns {AG123456.tif, AG123456.tif}

--------------------------

--Building final list which only contains the name of duplicate images once
set doubleImageList to {}
repeat with x from 1 to count of items of list1
set n to item x of list1
if n is in list2 and n is not in doubleImageList then set end of doubleImageList to n
end repeat
--returns {AG123456.tif}

-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------




-----------------------------------------------------------------------------------------
--LOCKING BOXES & GROUPS THAT ARE IN THE DOCUMENT MORE THAN ONCE
-----------------------------------------------------------------------------------------

--Locking all groups
select every group box
tell application "System Events" to key code 97 -->locking the group
set selection to null

--Creating a list of boxes that are only in the document once and a list of boxes that are in the document multiple times
set pictureBoxes to every picture box
set shadowedIDList to {}
set unshadowedIDList to {}
repeat with i from 1 to the number of pictureBoxes
set pictureBox to item i of pictureBoxes
set imagePath to file path of image 1 of pictureBox as string
if imagePath is in doubleImageList then
set shadowedIDList to shadowedIDList & uniqueID of pictureBox as string
else
set unshadowedIDList to unshadowedIDList & uniqueID of pictureBox as string
end if
end repeat


-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------




-----------------------------------------------------------------------------------------
--ADDING THE DROP SHADOWS TO BOXES THAT ARE ONLY IN THE DOCUMENT ONCE
-----------------------------------------------------------------------------------------

set shadowedBoxes to (every picture box whose uniqueID is in shadowedIDList)
set unshadowedBoxes to (every picture box whose uniqueID is in unshadowedIDList)


repeat with unshadowedBox in unshadowedBoxes

--Duplicating the picture box
set duplicateBox to duplicate unshadowedBox to after unshadowedBox
set duplicateImage to image 1 of duplicateBox


--Getting the bounds (coordinates) of the picture box
set y1 to coerce (item 1 of (bounds of unshadowedBox as list)) to real
set x1 to coerce (item 2 of (bounds of unshadowedBox as list)) to real
set y2 to coerce (item 3 of (bounds of unshadowedBox as list)) to real
set x2 to coerce (item 4 of (bounds of unshadowedBox as list)) to real


--Moving the top of the box down so it is only 0.08" high but the other coordinates are the same as the original box that was duplicated
set new_y1 to y2 - 0.08 as number
set content lock of duplicateImage to true
set bounds of duplicateBox to {new_y1, x1, y2, x2}


--Adding the drop shadow to the duplicated box
select duplicateBox
tell application "System Events" to key code 97 using {command down} -->Pressing Command F6 to activate the drop shadow item style
set selection to null

end repeat

-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------




-----------------------------------------------------------------------------------------
--SAVING & CLOSING THE DOCUMENTS
-----------------------------------------------------------------------------------------

close saving yes

-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------




end tell --end of tell document 1 block
end tell --end of tell Quark block
end repeat --end of first repeat loop
end timeout
end open --> This is the line of code that ends a droplet.

--------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------

--HANDLER THAT COUNTS THE NUMBER OF TIMES AN ITEM IS IN THE LIST
on count_matches(this_list, this_item)
set the match_counter to 0
repeat with i from 1 to the count of this_list
if item i of this_list is this_item then ¬
set the match_counter to the match_counter + 1
end repeat
return the match_counter
end count_matches
27
Quark XPress support / Adding drop shadows using system events and quark
« Last post by mbornbach on September 02, 2016, 02:55:36 PM »
28
I'm writing this script that duplicates images, changes the height of the duplicate image and adds a drop shadow to the duplicate image. The problem is some of the documents I'm working with will have some images that are already duplicated and have a drop shadow on the duplicate. I want the script to look through the document and lock all images that are in the document more than once. Then, once those images are locked, it can duplicate and create drop shadows for the unlocked images.

I have everything working EXCEPT the script only locks the duplicate image and not the original image. When it counts the images, it thinks there is only one image the first time it comes across the name, so it doesn't lock the first image. Since, one copy isn't locked, it creates a second drop shadow for the images that already had one. How do I change the part that checks how many times the image is in the document so that it locks BOTH copies of the image and not just one?



Code: [Select]
on open of droppedFiles --> This is the line of code that begins a droplet. 


tell application "Adobe InDesign CC 2014"

repeat with afile in droppedFiles
open afile

-----------------------------------------------------------------------------------------


--CREATING A DROP SHADOW OBJECT STYLE TO BE APPLIED LATER ON

tell document 1

try
set dropShadowStyle to object style "Drop Shadow"
on error
--The character style did not exist, so create it.
set dropShadowStyle to make object style with properties {name:"Drop Shadow", enable drop shadow:true, enable transparency:true, enable stroke:false}

tell dropShadowStyle
--Applying the drop shadow to the text
tell transparency settings
set properties of drop shadow settings to {mode:drop, use global light:true, opacity:40, spread:10.0, blend mode:multiply, noise:1.0, x offset:".02", y offset:".02", distance:".04", size:".04", effect color:"Black"}
end tell
end tell
end try

---------------------------------------------------------------


--COUNTING THE NUMBER OF TIMES AN IMAGE IS IN THE DOCUMENT
set TheGraphics to all graphics
set theLinksList to {}

repeat with n from 1 to (count TheGraphics)
set TheGraphic to item n of TheGraphics
set theLink to item link of TheGraphic
set linkName to name of item link of TheGraphic as string
set theLinksList to theLinksList & linkName
set matchCount to my count_matches(theLinksList, linkName)

--Getting the full path to each link to be used later on in thes script
set linkPath to file path of theLink as string

--other information that will be used later on in the script
set theImage to parent of theLink
set theFrame to parent of theImage

-----------------------------------------------------------------------------------------


--DUPLICATING PRODUCT IMAGES AND ADDING A DROP SHADOW IF THE FRAME THE IMAGE IS IN DOESN'T ALREADY HAVE A DROP SHADOW

if matchCount is greater than 1 then
set locked of theFrame to true
end if


if linkPath contains "1_4c IMAGES" then --Choosing everything that has 1_4c IMAGES in the path of it's link (basically all the product images)

--Getting coordinates of each side of the frame to be used in creating the duplicated frame for the drop shadow
--Geometric bounds is {top of frame, left side of frame, bottom of frame, right side of frame} or {item 1, item 2, item 3, item 4}
tell theFrame
set topOfFrame to item 1 of geometric bounds
set leftSideOfFrame to item 2 of geometric bounds
set bottomOfFrame to item 3 of geometric bounds
set rightSideOfFrame to item 4 of geometric bounds
set frameHeight to bottomOfFrame - topOfFrame as number --Getting height to be used later on in removing short frames with drop shadows
set offsetTopOfFrame to bottomOfFrame - 0.05 --This is the coordinate for the top of the duplicated frame that contains the drop shadow. We want it to be only slightly above the bottom of the frame.
end tell


--Duplicating the product image frame and resizing so it is only .05" tall instead of the full height of the image
--We just want a short little box at the bottom of the image for the drop shadow
if locked of theFrame is false then
set duplicateFrame to duplicate theFrame
set geometric bounds of duplicateFrame to {offsetTopOfFrame, leftSideOfFrame, bottomOfFrame, rightSideOfFrame}


--Sending the image frame with the drop shadow back one step
send backward duplicateFrame


--Applying the drop shadow to the duplicated image frame
tell duplicateFrame
apply object style using dropShadowStyle
end tell
end if


end if
end repeat


close saving yes



end tell
end repeat
end tell
end open







on count_matches(this_list, this_item)
set the match_counter to 0
repeat with i from 1 to the count of this_list
if item i of this_list is this_item then ¬
set the match_counter to the match_counter + 1
end repeat
return the match_counter
end count_matches
29
Adobe InDesign scripting / Re: Geometric Bounds out of order
« Last post by mbornbach on May 04, 2016, 04:51:51 PM »
Ah, I see. InDesign calculates the geometric bounds differently than I thought. Here's the working code. I may be back. I have to figure out how to calculate the placement for the rest of the boxes and then I'm going to measure the square inches of the boxes and put that information in the box.

Code: [Select]
on open droppedfiles
repeat with afile in droppedfiles
tell application "Adobe InDesign CC 2014"

--SETTING MEASUREMENTS TO INCHES
tell view preferences
--Measurement unit choices are:
--picas, points, inches, inches decimal, millimeters, centimeters, or ciceros
--Set horizontal and vertical measurement units to points.
set horizontal measurement units to inches decimal
set vertical measurement units to inches decimal

end tell


open afile


tell document 1

-----------------------------------------

--SETTING RULER ORIGIN TO ZERO
set rulerOrigin to ruler origin of view preferences
if rulerOrigin is not page origin then set ruler origin of view preferences to page origin --(spread origin/page origin/spine origin)


set rulerZeroPoint to zero point
if rulerZeroPoint is not {0, 0} then set zero point to {0, 0}

--Do Stuff

--Reset zero point and ruler origin
set zero point to rulerZeroPoint
set ruler origin of view preferences to rulerOrigin

-----------------------------------------

--SETTING PAGE HEIGHT AND WIDTH
tell page 1
set pageHeight to item 4 of bounds
set pageWidth to item 3 of bounds
end tell

set theGuides to every guide of page 1

-----------------------------------------

--CREATING EMPTY LISTS TO ADD TO LATER ON
set theGuideListVertical to {}
set theGuideListHorizontal to {}

--GETTING THE ORIENTATION (HORIZONTAL OR VERTICAL) FOR EVERY GUIDE
repeat with aGuide in theGuides --Telling it to loop through every guide
set guideOrientation to orientation of aGuide as string --Getting the orientation of every guide

--STORING THE LOCATION (MEASUREMENTS) OF EVERY VERTICAL GUIDE IN ONE LIST
if guideOrientation contains "«constant ****vert»" then --Determining if guides are vertical
set guideLocationVertical to location of aGuide --Getting the location of every guide
set theGuideListVertical to theGuideListVertical & guideLocationVertical --Creating the list with every location (measurement) of all the vertical guides

--STORING THE LOCATION (MEASUREMENTS) OF EVERY HORIZONAL GUIDE IN ANOTHER LIST
else if guideOrientation contains "«constant ****horz»" then --Determining if guides are horizontal
set guideLocationHorizontal to location of aGuide --Getting the location of every guide
set theGuideListHorizontal to theGuideListHorizontal & guideLocationHorizontal --Creating the list with every location (measurement) of all the horizontal guides
end if

end repeat


set hItemListCount to count number of items in theGuideListHorizontal
set vItemListCount to count number of items in theGuideListVertical


-----------------------------------------

--GETTING GEOMETRIC BOUNDS FOR LAST BOX

set lastFrameY1 to item 1 of theGuideListHorizontal as number
set lastFrameX1 to item 1 of theGuideListVertical as number


set xFrame1 to make text frame at page 1 of spread 1 with properties {geometric bounds:{lastFrameY1, lastFrameX1, pageWidth, pageHeight}}

display dialog geometric bounds of xFrame1 as string

end tell
end tell

end repeat
end open
30
Adobe InDesign scripting / Geometric Bounds out of order
« Last post by mbornbach on May 04, 2016, 03:57:08 PM »
I'm getting the location (measurements) for guides on a page and I'm creating text boxes for the areas within the guides. I'm using variables to calculate the text box bounds based on the page size and guide location. For some reason when I do this, the bounds end up in the wrong order. Then the box is in the wrong spot and it's the wrong size.  When I use actual numbers for the geometric bounds {"4 in", "5 in", "6 in", 7 in"} the bounds remain in the right order.  Any ideas?  Thanks!

Code: [Select]
on open droppedfiles
repeat with afile in droppedfiles
tell application "Adobe InDesign CC 2014"

--SETTING MEASUREMENTS TO INCHES
tell view preferences
--Measurement unit choices are:
--picas, points, inches, inches decimal, millimeters, centimeters, or ciceros
--Set horizontal and vertical measurement units to points.
set horizontal measurement units to inches
set vertical measurement units to inches

end tell


open afile


tell document 1

-----------------------------------------

--SETTING RULER ORIGIN TO ZERO
set rulerOrigin to ruler origin of view preferences
if rulerOrigin is not page origin then set ruler origin of view preferences to page origin --(spread origin/page origin/spine origin)


set rulerZeroPoint to zero point
if rulerZeroPoint is not {0, 0} then set zero point to {0, 0}

--Do Stuff

--Reset zero point and ruler origin
set zero point to rulerZeroPoint
set ruler origin of view preferences to rulerOrigin

-----------------------------------------

--SETTING PAGE HEIGHT AND WIDTH
tell page 1
set pageHeight to item 4 of bounds
set pageWidth to item 3 of bounds
end tell

set theGuides to every guide of page 1

-----------------------------------------

--CREATING EMPTY LISTS TO ADD TO LATER ON
set theGuideListVertical to {}
set theGuideListHorizontal to {}

--GETTING THE ORIENTATION (HORIZONTAL OR VERTICAL) FOR EVERY GUIDE
repeat with aGuide in theGuides --Telling it to loop through every guide
set guideOrientation to orientation of aGuide as string --Getting the orientation of every guide

--STORING THE LOCATION (MEASUREMENTS) OF EVERY VERTICAL GUIDE IN ONE LIST
if guideOrientation contains "«constant ****vert»" then --Determining if guides are vertical
set guideLocationVertical to location of aGuide --Getting the location of every guide
set theGuideListVertical to theGuideListVertical & guideLocationVertical --Creating the list with every location (measurement) of all the vertical guides

--STORING THE LOCATION (MEASUREMENTS) OF EVERY HORIZONAL GUIDE IN ANOTHER LIST
else if guideOrientation contains "«constant ****horz»" then --Determining if guides are horizontal
set guideLocationHorizontal to location of aGuide --Getting the location of every guide
set theGuideListHorizontal to theGuideListHorizontal & guideLocationHorizontal --Creating the list with every location (measurement) of all the horizontal guides
end if

end repeat


-----------------------------------------

--GETTING GEOMETRIC BOUNDS FOR LAST BOX

set lastFrameVerticalOffset to item 1 of theGuideListHorizontal as number
set lastFrameHorizontalOffset to item 1 of theGuideListVertical as number
set lastFrameHeight to (pageHeight - lastFrameHorizontalOffset) as number
set lastFrameWidth to (pageWidth - lastFrameVerticalOffset) as number

display dialog lastFrameVerticalOffset & " " & lastFrameHorizontalOffset & " " & lastFrameHeight & " " & lastFrameWidth as string

set xFrame1 to make text frame at page 1 of spread 1 with properties {geometric bounds:{lastFrameVerticalOffset, lastFrameHorizontalOffset, lastFrameHeight, lastFrameWidth}}

display dialog geometric bounds of xFrame1 as string

end tell
end tell

end repeat
end open
Pages: 1 2 [3] 4 5 6 7 ... 10