Copy link to clipboard
Copied
I have a need to mirror the Artboard, but I haven't been able to find a way to do this with C# and COM
Copy link to clipboard
Copied
What exactly do you mean by 'mirror' the artboard?
Copy link to clipboard
Copied
From the Menu if you select entire artbaord then Select Object from Menu, then Transform then Reflect horizontal will mirror the entire artboard, Mirroring is a graphics term for making a negative of a drawing ...
Copy link to clipboard
Copied
The reflection operation with the transform doesn't mirror the artboard, it does whatever object you have selected.
You will need to reference a pageItem (it could be a group with all the items of your document nested inside) and use the 'resize' command. Here is the javascript doc:
For C# it is probably:
pageItem.Resize(-1, 1, true, true, true, true, ... <-- I am not even sure what the C# COM parameters are for the last 2 arguments as in JavaScript we can simply omit them.
As it were, I myself am doing COM lately with Photoshop and will probably do an Illustrator experiment.
However, my standard experience has just always been to pass a javascript through the Application.DoJavaScript or Application.DoJavaScriptFile methods.
What I really like about it in C# is being able to debug it well.
Copy link to clipboard
Copied
I'll give that a try and see how it goes ...
Copy link to clipboard
Copied
Using the following code ...
// attempt to mirror object by using Javascript
appAI.ActiveDocument.SelectObjectsOnActiveArtboard();
string myScript = "var selectedObjects = app.activeDocument.selection;" +
"selectedObjects.resize(-1, 1, true, true, true, true);";
appAI.DoJavaScript(myScript);
Throws the following exception:
Error 24: selectedObjects.resize is not a function.
Line: 1
-> var selectedObjects = app.activeDocument.selection;selectedObjects.resize(-1, 1, true, true, true, true);
Copy link to clipboard
Copied
You should have a selection first.
You can select all selectable items in your document by using the command
app.executeMenuCommand("selectall");