OMG!!! this appears to work. Once again Pidge, you managed to pull through with an Illustrator question!
Mark, your explanation also makes perfect sense, but I was typing this response prior to noticing your reply. And to think I was going to remove this post. live and learn
Although I am very content with having the final missing part of my script NOW WORKING!, I am still curious about the logic.
For example, could I have also used:
set selection to every path item whose position is {0.0, 792.0}
How did you know to use control bounds, which also excepts the full dimensions?
FWIW, I included my complete script below. It takes a selected object (or objects) out of InDesign CS4, exports a PDF (twice actually), stores that to a folder. The Illustrator opens that file. Oddly I had to export as an RGB color space in order to fool the PDF to retaining any raster effects that Illustrator would better interpret once it opened the PDF. I have another post related to that found here.
http://macscripter.net/viewtopic.php?pid=36717#p36717
For those who attempt this script, you may find certain text with object styles applied to yield text with oversets when this PDF is opened in Illustrator. For this reason, I have assigned a keyboard shortcut ahead of time in InDesign, which I later have the script call using System Events, which will run that keyboard shortcut: break link to styles. There is a rather obvious comment section in my script that points to this.
It’s a rather esoteric script in terms of why one would need this. But in our production environment when we wish to create linked artwork files from InDesign set text, objects, and raster effects, it does come in handy
-- Try and make a new folder called FolderForGrabVectorFromInDesign in case it doesn't exist
try
set filePath to ((path to current user folder as Unicode text) & "Library:Application Support:Adobe:Adobe Illustrator CS4:en_US:")
set foldName to "FolderForGrabVectorFromInDesign"
tell application "Finder"
make new folder at folder filePath with properties {name:foldName}
end tell
end try
tell application "Finder"
try
set theNewFolder to (path to current user folder as Unicode text) & "Library:Application Support:Adobe:Adobe Illustrator CS4:en_US:FolderForGrabVectorFromInDesign"
delete entire contents of folder theNewFolder
end try
end tell
tell application "Adobe InDesign CS4"
activate
try
tell document 1
set sel to the selection
set myTextClasses to {text, insertion point, character, word, line, text style range, paragraph, text column}
set theClass to class of item 1 of selection
if class of item 1 of selection is in myTextClasses then
tell application "SystemUIServer"
activate
set userResponse to display dialog "You must use your selection tool and select the text frame. Do not use the Type Tool." & return & return & "Place selected text in its own text frame and run this script again." & return buttons {" Cancel "} default button " Cancel " with icon 2
if button returned of userResponse is " Cancel " then
tell application "Adobe InDesign CS4"
activate
end tell
return
error number -128
end if
return
end tell
end if
end tell
on error
display dialog "You must select a frame or multiple frames on your documet" buttons {"Cancel"} default button "Cancel" with icon 2
end try
end tell
set theCont to "NO"
tell application "Adobe InDesign CS4"
activate
copy
try
tell document 1
set sel to the selection
set theClass to class of sel
if theClass contains group or theClass contains list then
set theG to item 1 of selection
set theCount to count of page items in theG
--display dialog theCount as string
repeat with i from 1 to count of page items in theG
set theOpac to opacity of blending settings of transparency settings of page item i of theG
if theOpac is less than 100 then
tell application "SystemUIServer"
activate
set userResponse to display dialog "Warning!" & return & return & "You have an item with an opacity set below 100%." & return & return & "You should make a note of the blending mode in the transparency settings." & return & return & "After creating the Illustrator logo and placing it in InDesign, makes sure it looks the way it should." buttons {" Continue "} default button " Continue " with icon 2
end tell
set theCont to "Yes"
exit repeat
end if
set theBlend to blend mode of blending settings of transparency settings of item i of sel as text
if theCont contains "No" then
if theBlend is not equal to "normal" then
tell application "SystemUIServer"
activate
set userResponse to display dialog "Warning!" & return & return & "You have an item with a blending mode set to something other than normal." & return & return & "You should make a note of the blending mode in the transparency settings." & return & return & "After creating the Illustrator logo and placing it in InDesign, makes sure it looks the way it should." buttons {" Continue "} default button " Continue " with icon 2
end tell
exit repeat
end if
end if
end repeat
else
repeat with i from 1 to count of items in sel
set theOpac to opacity of blending settings of transparency settings of item i of sel
if theOpac is less than 100 then
tell application "SystemUIServer"
activate
set userResponse to display dialog "Warning!" & return & return & "You have an item with an opacity set below 100%." & return & return & "You should make a note of the blending mode in the transparency settings." & return & return & "After creating the Illustrator logo and placing it in InDesign, makes sure it looks the way it should." buttons {" Continue "} default button " Continue " with icon 2
end tell
set theCont to "Yes"
exit repeat
end if
set theBlend to blend mode of blending settings of transparency settings of item i of sel as text
if theCont contains "No" then
if theBlend is not equal to "normal" then
tell application "SystemUIServer"
activate
set userResponse to display dialog "Warning!" & return & return & "You have an item with a blending mode set to something other than normal." & return & return & "You should make a note of the blending mode in the transparency settings." & return & return & "After creating the Illustrator logo and placing it in InDesign, makes sure it looks the way it should." buttons {" Continue "} default button " Continue " with icon 2
end tell
exit repeat
end if
end if
end repeat
end if
end tell
-----------------------------------------------
-----------------------------------------------
-----------------------------------------------
-----------------------------------------------
-----------------------------------------------
--In this part I have I have assigned a keyboard shortcut in InDesign to to "Product area : Panel Menus" --> "Object Styles: Break Link to Style --- Default: Ctrl+Opt+Cmd+Clear", I probably don't need system, nor a keyboard shortcut to do this, but I never found an easy way to break the link to all object styles?
tell application "System Events"
try
tell application process "Adobe InDesign CS4"
set frontmost to true
key code 71 using {command down, option down, control down}
end tell
end try
end tell
-----------------------------------------------
-----------------------------------------------
-----------------------------------------------
-----------------------------------------------
-----------------------------------------------
set theDoc to active document
set theName to "ExportedImage"
copy
end try
end tell
tell application "System Events"
try
tell application process "Adobe InDesign CS4"
set frontmost to true
keystroke "a" using {command}
key code 71 using {command down, option down, shift down}
keystroke "g" using {command down}
end tell
end try
end tell
tell application "Adobe InDesign CS4"
set theDoc to make document
tell view preferences of theDoc
set horizontal measurement units to points
set vertical measurement units to points
set ruler origin to page origin
end tell
tell document preferences of theDoc
set properties to {page height:"792", page width:"612", page orientation:portrait, pages per document:1, column guide color:gray}
end tell
tell margin preferences of page 1 of theDoc
set properties to {column count:1, column gutter:12, top:0, left:0, bottom:0, right:0}
end tell
end tell
tell application "Adobe InDesign CS4"
paste
set theName to "ExportedImage.pdf" as text
set myPath to ((path to current user folder as Unicode text) & "Library:Application Support:Adobe:Adobe Illustrator CS4:en_US:FolderForGrabVectorFromInDesign:")
tell application "Adobe InDesign CS4"
activate
set oldProps to properties of PDF export preferences
set theProps to properties of PDF export preset "[Smallest File Size]"
set newProps to {view PDF:false, color bitmap sampling:none} & theProps
set properties of PDF export preferences to newProps
export active document format PDF type to (myPath & theName) without showing options
end tell
tell application "Adobe InDesign CS4"
activate
set oldProps to properties of PDF export preferences
set theProps to properties of PDF export preset "[Smallest File Size]"
set newProps to {view PDF:false, color bitmap sampling:none} & theProps
set properties of PDF export preferences to newProps
export active document format PDF type to (myPath & theName) without showing options
set oldProps to properties of PDF export preferences
end tell
delay 2
try
if saved of active document is false then
set theName to "TempFile"
save document 1 to ((path to current user folder as Unicode text) & "Library:Application Support:Adobe:Adobe Illustrator CS4:en_US:FolderForGrabVectorFromInDesign:ExportedImage.pdf") & theName
end if
end try
end tell
tell application "Adobe Illustrator"
activate
open file ((path to current user folder as Unicode text) & "Library:Application Support:Adobe:Adobe Illustrator CS4:en_US:FolderForGrabVectorFromInDesign:ExportedImage.pdf")
tell document 1
try
tell application "System Events"
tell application process "Adobe Illustrator CS4"
set frontmost to true
tell menu bar 1
tell menu bar item "File"
tell menu 1
tell menu item "Document Color Mode"
tell menu 1
click menu item "CMYK Color"
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end try
return
set selection to every path item whose control bounds is equal to {0.0, 792.0, 612.0, 0.0}
set theBox to the selection
delete theBox
end tell
end tell
tell application "Adobe InDesign CS4"
tell document 1
close saving no
end tell
end tell
tell application "SystemUIServer"
activate
display dialog "Finished. " buttons {"Ok"} default button "OK" giving up after 1.5
end tell
tell application "Adobe Illustrator"
activate
end tell