Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Flip / Mirror / Reflect whole Artboard

Explorer ,
Aug 10, 2022 Aug 10, 2022

Good day!
I was looking for a way to mirror everything in an artboard, keeping the artboard dimensions. In the past I used PlacedItem and did a .resize(-100,100) to mirror my placed item. My workflow changed and i wanted to mirror the Artboard before i export it as PDF. I looked around, but most solutions only mirror one selected element. Even if I group everything and try to mirror the GroupItem it will mirror according to the GroupItem dimensions and not according to the artboard. I will attach a Image of the original and the desired result. Thanks in advance!

WIDSnonamer_1-1660132145349.png

 

TOPICS
Scripting , SDK
1.5K
Translate
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 2 Correct answers

Guide , Aug 10, 2022 Aug 10, 2022

This is a basic idea:

var doc = app.activeDocument;
var temp = doc.pathItems.rectangle(0, 0, doc.width, doc.height);
app.executeMenuCommand("selectall");
app.executeMenuCommand("group");
app.selection[0].resize(-100,100);
app.executeMenuCommand("ungroup");
temp.remove();
Translate
Enthusiast , Aug 10, 2022 Aug 10, 2022

Resize has an option to specify a reference point for the transformation called scaleAbout.

Transformation.DOCUMENTORIGIN to this, you can move the reference point to virtually any position in the document.

 

var doc = app.documents[0] ;

// calculate reference point for resize
var bounds = doc.artboards[doc.artboards.getActiveArtboardIndex()].artboardRect ;
var artboardCenter = [(bounds[0] + bounds[2]) / 2, (bounds[1] + bounds[3]) / 2] ;

try {
  // store original DOCUMENTORIGIN
  var originalDocu
...
Translate
Adobe
Guide ,
Aug 10, 2022 Aug 10, 2022

This is a basic idea:

var doc = app.activeDocument;
var temp = doc.pathItems.rectangle(0, 0, doc.width, doc.height);
app.executeMenuCommand("selectall");
app.executeMenuCommand("group");
app.selection[0].resize(-100,100);
app.executeMenuCommand("ungroup");
temp.remove();
Translate
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 ,
Aug 11, 2022 Aug 11, 2022

nailed it. simple. elegant. 

Translate
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
Guide ,
Aug 11, 2022 Aug 11, 2022

@Disposition_Dev  Thanks.  A problem is that the "group" and "ungroup" menu commands move all items to one layer. 

Translate
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 ,
Aug 12, 2022 Aug 12, 2022

That works! Thank you, havent thought about solving it with a temp object

Translate
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
Enthusiast ,
Aug 10, 2022 Aug 10, 2022

Resize has an option to specify a reference point for the transformation called scaleAbout.

Transformation.DOCUMENTORIGIN to this, you can move the reference point to virtually any position in the document.

 

var doc = app.documents[0] ;

// calculate reference point for resize
var bounds = doc.artboards[doc.artboards.getActiveArtboardIndex()].artboardRect ;
var artboardCenter = [(bounds[0] + bounds[2]) / 2, (bounds[1] + bounds[3]) / 2] ;

try {
  // store original DOCUMENTORIGIN
  var originalDocumentOrigin = doc.rulerOrigin ;
  
  // set DOCUMENTORIGIN to artboard center
  doc.rulerOrigin = artboardCenter ;
  
  // resize items with Transformation.DOCUMENTORIGIN as reference point
  var targetItems = doc.selection ;
  for(var i = 0, len = targetItems.length ; i < len ; i++) {
    targetItems[i].resize(-100, 100, true, true, true, true, false, Transformation.DOCUMENTORIGIN) ;
  }
} catch(e) {
  alert(e) ;
} finally {
  doc.rulerOrigin = originalDocumentOrigin ;
}
Translate
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
Enthusiast ,
Aug 11, 2022 Aug 11, 2022

That's an interesting idea. I think we could add automatic selection of artboard content.

// resize items with Transformation.DOCUMENTORIGIN as reference point
doc.selectObjectsOnActiveArtboard();
var targetItems = doc.selection;

 

Translate
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 ,
Aug 12, 2022 Aug 12, 2022
LATEST

Thank you, it works fine! In my case i can group the selection before flipping to avoid a for statement and make it a little faster.

Translate
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