Copy link to clipboard
Copied
I can't locate any reference to the warp tool in the reference guide ?
Do you mean the Warp effect? If so, you may be able to use the Live Effect scripting technique - for which you will need to try and decipher certain necessary information, as described here: Re: PageItem.applyEffect(LiveEffectXML)
Copy link to clipboard
Copied
Do you mean the Warp effect? If so, you may be able to use the Live Effect scripting technique - for which you will need to try and decipher certain necessary information, as described here: Re: PageItem.applyEffect(LiveEffectXML)
Copy link to clipboard
Copied
Yes, Warp effect.
Copy link to clipboard
Copied
Getting a scriptable Warp effect.
First, I save a very basic Illustrator document which contains one shape with whichever Live Effect is desired.
The document is saved with no compression and with as many unnecessary things turned off as possible: ICC Profiles are unchecked and PDF compatibility is unchecked. Next, the document is opened inside a text editor where you will find the text which constitutes an .AI document, and most likely it contains information about the live effect applied to the one shape which was originally placed in the document.
This is a section of text where information about the Warp Tool is stored.
From here, the important string can be extracted:
/BasicFilter :
(Adobe Deform) 1 0 /Filter ,
1 /Visible ,
(Deform.aip) /PluginFileName ,
(Warp) /Title ,
/Dictionary : /NotRecorded ,
(Warp: Arc) /String (DisplayString) ,
0.449999988079071 /Real (DeformValue) ,
0 /Real (DeformVert) ,
0 /Bool (Rotate) ,
1 /Int (DeformStyle) ,
0 /Real (DeformHoriz) ,
; /Dict ;
Using the string, now can begin the efforts to transform this information into syntax as described by Carlos Canto here: https://forums.adobe.com/thread/1877476 .
'<LiveEffect name="Adobe Offset Path"><Dict data="R mlim 4 R ofst 20 I jntp 2 "/></LiveEffect>';
The 'name' seems to live under "/BasicFilter:" and all the pertinent info is somewhere in the block before a "/Dict;".
The data inside the .ai text is written in such an order:
In the LiveEffect XML syntax, they have got to be inside of a 'data' attribute, in this order with some extra transformation:
'<LiveEffect name="Adobe Deform"><Dict data="R DeformValue 45 R DeformVert 0 B Rotate 0 I DeformStyle 1 R DeformHoriz 0 "/></LiveEffect>';
Now the string is ready to test.
#target illustrator
function test(){
var doc = app.activeDocument;
var p = doc.selection[0];
var effectStr_2 = '<LiveEffect name="Adobe Deform"><Dict data="R DeformValue 45 R DeformVert 0 B Rotate 0 I DeformStyle 1 R DeformHoriz 0 "/></LiveEffect>';
p.applyEffect(effectStr_2);
};
test();
The result: I did get a Warp effect, but it was at 100%. I needed mine to be at 45%.
Well that's because I made a little mistake and wrote "45" for the DeformValue - whereas the actual value is between a 0 and 1L "0.45". Having changed this bit, it now works.
We shall see that the real working code is:
'<LiveEffect name="Adobe Deform"><Dict data="R DeformValue 0.45 R DeformVert 0 B Rotate 0 I DeformStyle 1 R DeformHoriz 0 "/></LiveEffect>';
#target illustrator
function test(){
var doc = app.activeDocument;
var p = doc.selection[0];
var effectStr_2 = '<LiveEffect name="Adobe Deform"><Dict data="R DeformValue 0.45 R DeformVert 0 B Rotate 0 I DeformStyle 1 R DeformHoriz 0 "/></LiveEffect>';
p.applyEffect(effectStr_2);
};
test();
There you have it, achieving a dynamic live warp effect using scripting!
If anything fails, in terms of unknown syntax for effects other than this one, post a question here on the forums and with enough luck, we may see the answer revealed to us by Carlos, as I did with my question about the Inner Glow - a syntax which contained nested elements. The gods have endowed him with great power.
Copy link to clipboard
Copied
Sorry, I should have mentioned; not warp, rather the warp tool. Is it the same procedure as warp ?
Copy link to clipboard
Copied
Oh you meant the tool ! Yea I completely mistook that part, unfortunately it just doesn't look like it's accessible to any scriptable technique, except maybe some programs which can execute their own mouse movements.
Copy link to clipboard
Copied
Script listener type is what you mean ?
Otherwise, bummer
Copy link to clipboard
Copied
Yea, I do not know too much about this area, but it's something I may want to get into so that I can make an example someday - here's a sample search result for Windows' AutoHotKey program: https://autohotkey.com/board/topic/43887-hold-click-mouse-moves-down/
Copy link to clipboard
Copied
One can't even use a "listener" plugin in Illustrator and output the code used for the warp tool, arghh.
Copy link to clipboard
Copied
Certainly without such a plugin already in existence, I think.
Copy link to clipboard
Copied
?
Copy link to clipboard
Copied
If someone made a plugin which can record and play the tools usage, maybe it would be possible, I'm not sure what Adobe would think about something like that.
Copy link to clipboard
Copied
Thanks SillyV, bummer.
Copy link to clipboard
Copied
Hello,
Thank you very much for your answer on this post regarding Live Effects. It certainly helped me since I can now warp my object. However, I still have a minor issue after using this tool. Namely, after warping, the shape of the object changes but the selection stays the same. I have a specified canvas size and therefore the selection may stay inside the canvas while the shape actually does not. Since my script also exports the PDF it therefore cuts off parts of the shape.
I have seen that using envelope distort updates the selection so that the entire shape is included after warping. However, I cannot find any way to apply the envelope distort warp other than this: