问题
My script should select some items and apply Effect->3D->Extrude&bevel to them. Which objects and methods should be used?
I use JavaScript in AI CS6.
Thanks.
-- Update: I need to set the values for effect parameters (angles, depth etc.) in script.
-- Update 2: Probably it's possible to patch an AI file with needed values for the GraphicStyle, and then open it and apply the style where needed. But I'd like to know if there is less dirty solution.
回答1:
Using documents[0].selection[0].reflect.properties
in ExtendScript toolkit to find out what properties basic paths have, I don’t see any way to set this effect directly.
When I search the JavaScript Reference for Illustrator, the only mention I see of appearance is when it talks about graphic styles.
So what I tried was drawing two rectangles, applying the 3D effect to one of them, and saving it as a new graphic style:
Then in the script, you can select the other rectangle and then apply the graphic style with
documents[0].graphicStyles[6].applyTo(documents[0].selection[0])
Unfortunately, the documentation does say
Scripts cannot create new graphic styles.
One thing that might be work would be to distribute a document with the script that has all the graphic styles you might want to apply, and then apply them to objects in the target document…
来源:https://stackoverflow.com/questions/17448553/scripting-adobe-illustrator-how-to-apply-an-effect