AppleScript 'fill color' with Pixelmator Pro 1.8

Is something not working like it should? Let us know.
User avatar

2020-10-22 14:12:49

Pixelmator Pro 1.8... AppleScript 'fill color'

Its little confusing how to get value of integer of colors with fill color... its possible to set a color value to layer object
but its not possible to get the value to store in variable.

Is this a bug??

-- This works.
tell application "Pixelmator Pro"
tell front document to tell styles of current layer
set fill color to {25000, 25000, 45000}
end tell
end tell

-- This doesn't work
tell application "Pixelmator Pro"
tell front document to tell styles of current layer
-- This doesn't work
its properties
-- error "Pixelmator Pro got an error: AppleEvent handler failed." number -10000

-- This doesn't work
-- its fill color
-- error "Pixelmator Pro got an error: AppleEvent handler failed." number -10000

-- This works
its fill opacity
end tell
end tell
User avatar

2020-10-22 15:40:50

It looks like there is a bug with getting the values of color-based layer style properties (fill color/stroke color/shadow color/inner shadow color). I've reported this to the devs, we'll see what we can do to fix it! In the meantime, if you'd like to get all the styles of a layer, you don't necessarily have to use the properties keyword. Here's a script that should work:
tell application "Pixelmator Pro"
	tell the front document
		-- Put all the layer styles into the someLayerStyles variable
		set someLayerStyles to the styles of the current layer
		-- Set the styles of some other layer to the styles in the someLayerStyles variable
		set the styles of the second layer to someLayerStyles
	end tell
end tell
User avatar

2020-10-22 17:52:04

Thanks for your suggestion, have you check my Pixelmator Pro Library at
https://forum.latenightsw.com/t/i-made-a-pixelmator-pro-library/2712?u=fredrik71

Would it be possible to suggestion feature for future Pixelmator Pro ??

Regards.
User avatar

2020-10-23 09:50:11

Thanks for sharing the link to the library! What kind of things do you use it for, if you don't mind me asking?
User avatar

2020-10-23 18:16:09

AppleScript itself is a very old scripting language and Apple have not update it for many years. It means the only way to make it more powerful is to build libraries of function/handlers. The scriptable application model doesn't have to be limited to a few line of code in a tell block.

It could be so much more and that... and not limited to what target application will support. We could use PyObjC, AppleScriptObjC, JavaScriptCore, AppKit, CoreImage or Foundation framework.

The benefit is many from speed to possibility to make same things in less time.

Scripting is about making shortcuts, less coding to do more things in less time. Thats why scripting libraries is a great approach. Also any serious AppleScript users know AppleScript is limited on how big a script could be so a workaround is to use libraries. I'm a strong believer of sharing knowledge thats why I made it. I also think many people maybe struggle to understand the syntax because its different. To get knowledge is limited and many times guessing and thats why people seek other solutions.

Only by sharing its possible to extend knowledge, update and making better work.

Any application who has great scripting API could do things in less time, in repeated tasks and have high quality control. When time is money in a dynamic world who ask for more with less time and people.

Why did Pixelmator Team support AppleScript when everyone else did not. Its bold I guess to be different and not limited to what it could really do and be open about it and express ideas and thoughts.

And maybe their is a misunderstanding what AppleScript is all about when so many compare it other scripting language.
User avatar

2020-11-19 13:21:47

This bug (along with a few other AS bugs) should've now been fixed with Pixelmator Pro 2.0. :pray:
User avatar

2020-11-19 23:03:07

Great, now you all have more time to innovate :)
User avatar

2020-11-20 12:43:30

Which is great for everyone! :smiley:
User avatar

2020-11-20 20:28:56

Do you have a list what Pixelmator team did in this release for AppleScript, it will be helpful to me ??
User avatar

2020-11-26 14:08:28

It was just bug fixes – they're the last bullet point in the release notes here: https://www.pixelmator.com/pro/updates/