• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • PortuguĂȘs
  • æ—„æœŹèȘžă‚łăƒŸăƒ„ニティ
    Dedicated community for Japanese speakers
  • 한ꔭ ì»€ëź€ë‹ˆí‹°
    Dedicated community for Korean speakers
Exit
0

How to reflect in script?

New Here ,
Dec 10, 2008 Dec 10, 2008

Copy link to clipboard

Copied

Hi,

I want the equivalent of choosing Object > Transform > Reflect, across the Vertical axis. How would I do this with JavaScript?

Thanks,

Max
TOPICS
Scripting

Views

3.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 13, 2015 Jan 13, 2015

Try below code:

function applyTM(tg, a, b, c, d) {

  var tm = new Matrix();

  tm.mValueA = a;

  tm.mValueB = b;

  tm.mValueC = c;

  tm.mValueD = d;

  tm.mValueTX = 0;

  tm.mValueTY = 0;

  tg.transform(tm,true,true,true,true,1);

  app.redraw();

  }

applyTM (app.activeDocument.selection[0],-1,0,0,1);

if you want to transform horizontal:

applyTM (app.activeDocument.selection[0],1,0,0,-1);

Ten

Votes

Translate

Translate
Adobe
New Here ,
Dec 15, 2008 Dec 15, 2008

Copy link to clipboard

Copied

Max this is AppleScript but should at least give you a clue to using the transform object and matrix values. You should be able to translate to JavaScript.

tell application "Adobe Illustrator"
activate
set Doc_Ref to the current document
tell Doc_Ref
set Group_XY to position of group item 1 of layer 1
set RefVert_Matrix to ÂŹ
{class:matrix, mvalue_a:-1.0, mvalue_b:0.0, mvalue_c:0.0, mvalue_d:1.0, mvalue_tx:0.0, mvalue_ty:0.0}
transform group item 1 of layer 1 using RefVert_Matrix about center
set position of group item 1 of layer 1 to Group_XY
end tell
end tell

BTW when ever I have used this it always appears to move very slightly so check your bounds before and after.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 30, 2014 Dec 30, 2014

Copy link to clipboard

Copied

hello,

are there any way to do that in java script not apple

Object > Transform > Reflect, across the Vertical axis

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 13, 2015 Jan 13, 2015

Copy link to clipboard

Copied

Try below code:

function applyTM(tg, a, b, c, d) {

  var tm = new Matrix();

  tm.mValueA = a;

  tm.mValueB = b;

  tm.mValueC = c;

  tm.mValueD = d;

  tm.mValueTX = 0;

  tm.mValueTY = 0;

  tg.transform(tm,true,true,true,true,1);

  app.redraw();

  }

applyTM (app.activeDocument.selection[0],-1,0,0,1);

if you want to transform horizontal:

applyTM (app.activeDocument.selection[0],1,0,0,-1);

Ten

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 13, 2015 Jan 13, 2015

Copy link to clipboard

Copied

transform > reflect objects in illustrator via javascript

 

 

 

----------------------------------------------------------

[ edited by pixxxelschubser ] --> link updated

 

transform > reflect objects in illustrator via javascript 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 14, 2015 Jan 14, 2015

Copy link to clipboard

Copied

Hi,

There's a script created by our friend Gustavo Del Vechio (Reflex 1.0), he made a tool for that, follow your site:

Scripts (English) | NĂșcleo do Illustrator

Thanks again Gustavo!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Feb 27, 2018 Feb 27, 2018

Copy link to clipboard

Copied

No reason for this comment other than to point that, it contains legends of our industry (not talking about myself of course)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 26, 2023 Oct 26, 2023

Copy link to clipboard

Copied

var totalMatrix = app.getScaleMatrix(-100, 100); // Cria a matriz de escala

var layer = app.activeDocument.activeLayer; // Obtém a camada ativa

for (var i = 0; i < layer.pageItems.length; i++) {
// Itera por todos os itens na camada
var currentItem = layer.pageItems[i];

// Verifica se o nome do item Ă© "verso" antes de aplicar a matriz de escala
if (currentItem.name === "verso") {
currentItem.transform(totalMatrix);
}
}

This code works!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 26, 2023 Oct 26, 2023

Copy link to clipboard

Copied

var totalMatrix = app.getScaleMatrix(-100, 100); // Cria a matriz de escala

var layer = app.activeDocument.activeLayer; // Obtém a camada ativa

for (var i = 0; i < layer.pageItems.length; i++) {
        // Itera por todos os itens na camada
         var currentItem = layer.pageItems[i];

 

        // Verifica se o nome do item Ă© "verso" antes de aplicar a matriz de escala
        if (currentItem.name === "verso") {
              currentItem.transform(totalMatrix);

       }
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 26, 2023 Oct 26, 2023

Copy link to clipboard

Copied

LATEST

var totalMatrix = app.getScaleMatrix(-100, 100); // Create the scale matrix

 

var layer = app.activeDocument.activeLayer; // Get the active layer

 

for (var i = 0; i < layer.pageItems.length; i++) {
        // Iterate through all items in the layer
        var currentItem = layer.pageItems[i];

 

        // Check if the item's name is "verso" before applying the scale matrix
        if (currentItem.name === "verso") {
                currentItem.transform(totalMatrix);
        }
}

But u got change the name of the object to "verso" and the layers to "Camada 1"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines