I'm trying to change a colour in an illustrator document from one color the another heres what i've got but it keeps saying "can't find color" i'm not sure what i'm doing wrong?
tell application "Adobe Illustrator"
if exists color is equal to "C=0 M=0 Y=0 K=90" then
set color to "C=0 M=0 Y=0 K=100"
end if
end tell
tell application "Adobe Illustrator"
set allMyItems to every path item of current document whose fill color is {cyan:0.0, magenta:0.0, yellow:0.0, black:90.0}
repeat with myItem in allMyItems
set fill color of myItem to {cyan:0.0, magenta:0.0, yellow:0.0, black:100.0}
end repeat
end tell
Looks like it cant understand what exactly color are you setting (i.e. fill color, stroke color, etc.). Or if you just setting a variable named 'color' than you probably need to choose another name (something like myColor) because this one is reserved
Related
I'm trying to use Apple script to set the font color of all selected PowerPoint shapes. I used something similar to this to set fill and line color, but I haven't been able to get it to work for font color.
tell application "Microsoft PowerPoint"
set theShapeRange to shape range of selection of active window
set n to (count shapes of theShapeRange)
repeat with i from 1 to n
tell shape i of theShapeRange
set font color of text range of it to {99, 99, 99}
end tell
end repeat
end tell
Based on the guidance provided by Mockman in a comment above, this seems to work.
tell application "Microsoft PowerPoint"
set theShapeRange to shape range of selection of active window
set n to (count shapes of theShapeRange)
repeat with i from 1 to n
tell shape i of theShapeRange
set font color of font of text range of text frame of it to {99, 99, 99}
end tell
end repeat
end tell
Using AppleScript, I want to alter the x and y position of a particular image on every slide of a Keynote document. Once Keynote is running and activated, the following code works...
tell the front document
set the current slide to slide 1
tell the current slide
set thisImage to image 1
set position of thisImage to {10,10}
end tell -- current slide
end tell -- front document
... but it's too fragile. If my image is not the first one ("image 1") then I'll be changing the position of the wrong object. I can't find anything in the scripting dictionaries or in on-line examples about expressing an object specifier for a particular image. I tried several variations on things like...
set thisImage to image with file name "my-file.png"
... to no avail. Any and all advice is appreciated. Thanks!
This works in Keynote 8.2, but to be honest, I'm not sure why.
set thisImage to image {name:"my-file.png"}
However, if you want to then ask thisImage what its name is, you have to ask for its file name, e.g.…
file name of thisImage
Every time I use any presentation software, I somehow like them all less.
You have some redundancy (around 'current slide') so here is my take:
tell slide 1 of the front document
set thisImage to image {name:"my-file.png"}
set position of thisImage to {10, 10}
end tell
Finally, since your objective is to cycle through every slide in the deck, you could try this:
tell front document
repeat with i from 1 to count of slides
tell slide i to set position of image {name:"my-file.png"} to {10, 10}
end repeat
end tell
Upon further review, the earlier answer doesn't work, or no longer works. Apparently the name specifier...
set thisImage to image {name:"my-file.png"}
... doesn't actually specify a name in that manner. Here is my ugly workaround:
tell the current slide
set imageCount to the count of images
repeat with i from 1 to imageCount
set thisImage to image i
if file name of thisImage = "myTargetFile.png" then
set position of thisImage to {10, 10}
exit repeat -- Ugly programming, look away.
end if
end repeat
end tell
I have a templated Keynote file with some slides and all the slides each have 2 shapes in them. I want to be able to say something like, "hey give me shape 2 of slide 2". The purpose of this, is so that i can add text items directly to that shape. below is the code that I have right now.
I am using the latest Keynote 6.5.2 & Yosemite.
tell application "Keynote"
activate
tell document 1
set anniversary to "Anniversaries"
set myShape to shape 2 of slide 2
tell myShape
set thisTextItem to make new text item with properties {object text:anniversary}
#log thisTextItem
tell thisTextItem
set the size of its object text to 144
set the color of its object text to "blue"
end tell
end tell
end tell
end tell
I can tell slide 2 by itself and of course i get a big text item for slide 2 with text "Anniversaries" and colored blue but its only slide 2... not within shape 2 of slide 2.
With this code it gives me a pop up error when running the script:
Result:
error "Keynote got an error: Can’t make or move that element into that
container." number -10024
what does this mean? do i not have access to shapes within slides?? Any help/info/examples of setting text within a shape that is within a slide would be beneficial. Thanks!
You can set the properties of the text in a shape, you can't insert a text item object in a shape.
tell application "Keynote"
tell document 1
tell shape 2 of slide 2
set object text to "Anniversaries"
tell object text
set it's size to 44
set it's color to {0, 0, 65535} -- blue
end tell
end tell
end tell
end tell
I was trying to use this code.
tell application "Adobe Illustrator"
tell front document
set properties of every path item whose stroke weight is less than 0.2 to {stroke width:0.2}
end tell
end tell
I see no reason why it shouldn't work, but it gets hung up on the phrase "path item." I don't understand what else I should do! I'm trying to get this to work in Illustrator CS6.
Full disclosure: I'm doing this on CS4, but it really should be the same, although I suppose it is possible (unlikely) that "stroke width" changed to "stroke weight". I think you also need to specify the layer. Try something like (of course you'll have to specify the correct layer) this; it works for me:
tell application "Adobe Illustrator"
tell front document
set stroke width of (every path item of layer 1 of it whose stroke width is less than 0.2) to 0.2
end tell
end tell
The following script, when run in AppleScript Editor returns as text the autoshape type of the objects on the page. However, when run from the applescript menu from within PowerPoint, it returns a script constant instead.
I'm using a more complicated version of this to send properties of the objects to different applications based on what auto shape type it is... tables go one place, placeholders another, and rectangles et al to third. I'm also launching this from within PPT to push out the data, and can't really pull it from any of the other apps, so the AppleScript menu would be where I want it to be.
Can anyone tell me why the same script gives two results?
Thanks,
Alex
tell application "Microsoft PowerPoint"
set currentSlideNumber to slide index of slide range of selection of document window 1
set theSlide to slide currentSlideNumber of active presentation
end tell
getProperty(theSlide)
to getProperty(theSlide)
tell application "Microsoft PowerPoint"
repeat with thisShape in (get every shape of theSlide)
set shapeType to shape type of thisShape
set shapeContent to content of text range of text frame of thisShape
display alert (shapeType as string)
end repeat
end tell
end getProperty
Converting constants (or application properties which standard applescript doesn't understand) to text is tricky. My guess is that when in the powerpoint menu the script understands the constant better and thus you see that.
In any case, I had the same issue with Finder constants and decided to handle the conversion to text myself with an if statement. It's a cumbersome solution because you have to account for every constant but at least you know it will happen properly.
Here's an example. Suppose there is a shape constant of "rect" which stands for a rectangle, and "circ" standing for circle.
NOTE: you can probably use the name of the actual property instead of the constant in the code.
to getProperty(theSlide)
tell application "Microsoft PowerPoint"
repeat with thisShape in (get every shape of theSlide)
set shapeType to shape type of thisShape
if shapeType is <<rect>> then
set shapeTypeText to "rectangle"
else if shapeType is <<circ>> then
set shapeTypeText to "circle"
end if
set shapeContent to content of text range of text frame of thisShape
display alert (shapeTypeText)
end repeat
end tell
end getProperty