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

Problème script de rotation groupée d'éléments

Explorer ,
Apr 14, 2023 Apr 14, 2023

Copy link to clipboard

Copied

Bonjour,
Je souhaitais créer un script qui permet de tourner uniquement les éléments importés de ma bibliothèque et le texte qui se trouvent dans les calques "TEXTE" "PICTO PI" "PICTO PE" PICTO EXT PORTATIF" et j'aimerais rrajouter une règle qui empêche l'élément importé qui s'appelle "Itinéraire d’évacuation" de tourner. 
J'ai réussi à mettre en place un script qui fonctionnait pendant un temps mais qui ne fonctionne plus..

function rotateLayerItems(layer, angle) {
  var items = layer.pageItems;
  for (var i = 0; i < items.length; i++) {
    var currentItem = items[i];
    if (currentItem.typename !== "PlacedItem" && currentItem.typename !== "TextFrame") {
      continue;
    }
    if (currentItem.typename === "PlacedItem" && currentItem.name === "Itinéraire d’évacuation") {
      continue;
    }
    if (currentItem.typename === "Group" && currentItem.name === "Itinéraire d’évacuation") {
      continue;
    }
    currentItem.rotate(angle, true, true, true, true, Transformation.CENTER);
  }
}


// Fonction d'initialisation de la fenêtre de dialogue
function initDialog() {
  var dialog = new Window("dialog", "Rotation répartie");
  dialog.alignChildren = "left";

  var ninetyButton = dialog.add("button", undefined, "90°");
  ninetyButton.onClick = function() {
    var layers = [app.activeDocument.layers.getByName("TEXTE"), app.activeDocument.layers.getByName("PICTO PI"), app.activeDocument.layers.getByName("PICTO PE"), app.activeDocument.layers.getByName("PICTO EXT")];
    for (var i = 0; i < layers.length; i++) {
      rotateLayerItems(layers[i], 90);
    }
    dialog.close();
  }

  var oneEightyButton = dialog.add("button", undefined, "180°");
  oneEightyButton.onClick = function() {
    var layers = [app.activeDocument.layers.getByName("TEXTE"), app.activeDocument.layers.getByName("PICTO PI"), app.activeDocument.layers.getByName("PICTO PE"), app.activeDocument.layers.getByName("PICTO EXT")];
    for (var i = 0; i < layers.length; i++) {
      rotateLayerItems(layers[i], 180);
    }
    dialog.close();
  }

  var twoSeventyButton = dialog.add("button", undefined, "270°");
  twoSeventyButton.onClick = function() {
    var layers = [app.activeDocument.layers.getByName("TEXTE"), app.activeDocument.layers.getByName("PICTO PI"), app.activeDocument.layers.getByName("PICTO PE"), app.activeDocument.layers.getByName("PICTO EXT")];
    for (var i = 0; i < layers.length; i++) {
      rotateLayerItems(layers[i], 270);
    }
    dialog.close();
  }

  dialog.show();
}

// Lancement de la fenêtre de dialogue
initDialog();
TOPICS
Draw and design , Scripting , Third party plugins , Tools

Views

221

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
Adobe
Guide ,
Apr 15, 2023 Apr 15, 2023

Copy link to clipboard

Copied

LATEST

The script will silently fail if any of the aforementioned named layers doesn't exist.  Is that the case?  And the script will not proceed unless the items to be rotated are placed items or text frames. Is that the intention?  Also, the typename of a group is "GroupItem", not "Group". 

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