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

Changer de l'ordre de groupes de layers

Explorer ,
Jan 09, 2024 Jan 09, 2024

Copy link to clipboard

Copied

Bonjour,

 Connaissez vous une méthode ou un script qui permet de changer l'ordre de groupes de layers. Je m'explique, j'ai 3 layers (A,B,C) puis 3 layers (D,E,F), etc. Je voudrais changer l'ordre en conservant l'ordre dans les groupes. Par exemple changer l'ordre des layers A, B, C, D, E, F en D, E, F, A, B, C.

Si vous avez une idée je suis preneur ma comp contients plus de 200 layers et j'aimerais trouver un moyen de le faire automatiquement.

Merci

TOPICS
Expressions , How to

Views

533

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

Enthusiast , Jan 10, 2024 Jan 10, 2024

OK, maintenant, c'est clair:

 

screenshot.png

 

 

Reverse_Layers_Order_by_Group.jsx

 

 

(function (thisObj) {
  buildUI(thisObj);

  function buildUI(thisObj) {
    var palette = new Window("palette", "Reverse Layers Order by Group", undefined, { resizeable: true });
    palette.orientation = "column";
    palette.alignChildren = ["center", "top"];
    palette.spacing = 10;
    palette.margins = 10;

    var group1 = palette.add("group");
    group1.orientation = "row";
    group1.alignChildren = ["left", "center"];
...

Votes

Translate

Translate
Enthusiast ,
Jan 09, 2024 Jan 09, 2024

Copy link to clipboard

Copied

Quand tu dis groupe de layer, c'est la couleur des labels?

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 ,
Jan 09, 2024 Jan 09, 2024

Copy link to clipboard

Copied

merci pour ton message. Groupe layer A, B, C puis groupe D, E, F, etc.

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
Enthusiast ,
Jan 09, 2024 Jan 09, 2024

Copy link to clipboard

Copied

Essaie ça:

File -> Scripts -> Run Script File -> move_group.jsx

 

move_group.jsx content:

(function(thisObj) {

  buildUI(thisObj);

  function buildUI(thisObj) {
    var palette = new Window("palette", undefined, undefined, {
      resizeable: true
    });
    palette.text = "MOVE GROUP";
    palette.preferredSize.width = 240;
    palette.orientation = "column";
    palette.alignChildren = ["center", "top"];
    palette.spacing = 10;
    palette.margins = 10;

    var button1 = palette.add("button", undefined, undefined, {
      name: "button1"
    });
    button1.text = "LAYERS GROUP TO MOVE";
    button1.preferredSize.width = 220;

    var group1 = palette.add("group", undefined, {
      name: "group1"
    });
    group1.orientation = "row";
    group1.alignChildren = ["left", "center"];
    group1.spacing = 10;
    group1.margins = 0;
    group1.enabled = false;

    var button2 = group1.add("button", undefined, undefined, {
      name: "button2"
    });
    button2.text = "MOVE AFTER";
    button2.preferredSize.width = 100;

    var button3 = group1.add("button", undefined, undefined, {
      name: "button3"
    });
    button3.text = "MOVE BEFORE";
    button3.preferredSize.width = 100;

    palette.show();

    if (palette instanceof Window) {
      palette.center();
      palette.show();
    } else {
      palette.layout.layout(true);
      palette.layout.resize();
    }

    var proj = app.project;
    var thisComp = proj.activeItem;
    var selectedGroup = [];

    button1.onClick = function() {
      selectedGroup = thisComp.selectedLayers;
      group1.enabled = true;
    }
    button2.onClick = function() {
      app.beginUndoGroup("moveAfter");
      for (var i = selectedGroup.length - 1; i >= 0; i--) {
        selectedGroup[i].moveAfter(thisComp.selectedLayers[0])
      }
      app.endUndoGroup();
    }

    button3.onClick = function() {
      app.beginUndoGroup("moveBefore");
      for (var i = 0; i < selectedGroup.length; i++) {
        selectedGroup[i].moveBefore(thisComp.selectedLayers[0])
      }
      app.endUndoGroup();
    }
  }
})(this);

 

 

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
Enthusiast ,
Jan 09, 2024 Jan 09, 2024

Copy link to clipboard

Copied

Après reflexion, je ne vois pas trop de différence entre utiliser le script et déplacer les groupes manuellement...

Il y a un truc qui a dû m'échapper. 🤔

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 ,
Jan 09, 2024 Jan 09, 2024

Copy link to clipboard

Copied

MERCI BEAUCOUP ! Etrange le script ne fonctionne pas chez moi. Mais l'idée ce n'est pas sur 7 layers, il faut imaginer une comp avec 200 layers et de vouloir changer l'ordre des groupes de layers.

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
Enthusiast ,
Jan 09, 2024 Jan 09, 2024

Copy link to clipboard

Copied

Regarde la vidéo, le déplacement de la souris, revient à ce que tu ferais manuellement.

- Tu sélectionnes ton groupe de calques.

-  Ensuite avec la souris, tu vas là où tu veux les déplacer.

Et avec le script, c'est encore pire, tu fais les mêmes déplacements sauf que tu as les déplacements de la souris vers les boutons du script en plus.

 

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 ,
Jan 09, 2024 Jan 09, 2024

Copy link to clipboard

Copied

Oui je suis d'accord avec quelques layers à la souris, seulement imagine 300 layers ABC puis DEF puis GHI, etc, jusqu'a 300. Les layers ABC qui sont en index 1 (A),2 (B),3 (C) tu voudrais qu'ils soient en index 298 (A),299(B),300(C) et ainsi de suite pour tous les groupes.

Merci

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
Enthusiast ,
Jan 09, 2024 Jan 09, 2024

Copy link to clipboard

Copied

Je pense qu'il faut un panel comme ça:

screenshot.png

 

Le truc, c'est comment savoir à quoi correspond Group 1, Group 2... dans la composition.

Je ne pense pas qu'on puisse mettre un carré de couleur dans les list boxes.

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 ,
Jan 09, 2024 Jan 09, 2024

Copy link to clipboard

Copied

Il faudrait pouvoir dire que par exemple tous les 3 layers, l'ordre change

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
Enthusiast ,
Jan 09, 2024 Jan 09, 2024

Copy link to clipboard

Copied

Donc à la place, de:

Group 1, je mets [1-3]

Group 2, je mets [4-6]

et ainsi de suite...

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 ,
Jan 09, 2024 Jan 09, 2024

Copy link to clipboard

Copied

oui exactement !

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
Enthusiast ,
Jan 09, 2024 Jan 09, 2024

Copy link to clipboard

Copied

OK, je regarde ça demain matin.

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
Enthusiast ,
Jan 09, 2024 Jan 09, 2024

Copy link to clipboard

Copied

Ca à l'air de faire le job: 

move_layers_by_group.jsx

 

(function (thisObj) {
  buildUI(thisObj);

  function buildUI(thisObj) {
    var palette = new Window("palette", "Move Layers by Group", undefined, { resizeable: true });
    palette.orientation = "column";
    palette.alignChildren = ["center", "top"];
    palette.spacing = 10;
    palette.margins = 10;

    var group1 = palette.add("group");
    group1.orientation = "row";
    group1.alignChildren = ["left", "center"];
    group1.spacing = 10;
    group1.margins = 0;

    var listbox1 = group1.add("listbox", undefined, undefined, { items: [] });
    listbox1.alignChildren = ["left", "center"];

    var listbox2 = group1.add("listbox", undefined, undefined, { items: ["Move After", "Move Before"] });
    listbox2.selection = 0;

    var listbox3 = group1.add("listbox", undefined, undefined, { items: [] });

    var group2 = palette.add("group");
    group2.orientation = "row";
    group2.alignChildren = ["left", "center"];
    group2.spacing = 10;
    group2.margins = 0;

    var button1 = group2.add("button");
    button1.text = "REFRESH LISTS";
    var edittext1 = group2.add('edittext', undefined, "3");
    var button2 = group2.add("button");
    button2.text = "MOVE GROUP";

    if (palette instanceof Window) {
      palette.center();
      palette.show();
    } else {
      palette.layout.layout(true);
      palette.layout.resize();
    }

    var proj = app.project;

    button1.onClick = function () {
      listGroups();
    }

    button2.onClick = function () {
      var thisComp = proj.activeItem;
      if (!thisComp) {
        alert('No active composition');
        return false;
      }
      var lb1Selection = listbox1.selection;
      var lb2Selection = listbox2.selection;
      var lb3Selection = listbox3.selection;

      if (lb1Selection && lb2Selection && lb3Selection) {
        if ((lb1Selection.index == lb3Selection.index) ||
          (lb1Selection.index + 1 == lb3Selection.index && lb2Selection.index == 1) ||
          (lb1Selection.index - 1 == lb3Selection.index && lb2Selection.index == 0)) {
          return false
        }
        app.beginUndoGroup("move");
        var step = Math.max(1, Number(edittext1.text));
        if (step != Number(edittext1.text)) {
          edittext1.text = step;
        }
        var g1 = lb1Selection.index * step + 1;
        var g2 = lb3Selection.index * step + 1;
        var selectedLayers = [];

        for (var i = g1 + step - 1; i >= g1; i--) {
          selectedLayers.push(thisComp.layer(i));
        }

        var toIndex = (lb2Selection.index === 0) ? Math.min(thisComp.numLayers, g2 + step - 1) : g2;

        for (var j = 0; j < selectedLayers.length; j++) {
          if (lb2Selection.index === 0) {
            selectedLayers[selectedLayers.length - 1 - j].moveAfter(thisComp.layer(toIndex));
          } else {
            selectedLayers[j].moveBefore(thisComp.layer(toIndex));
          }
        }
        app.endUndoGroup();
      } else {
        alert('Select groups and action');
      }
    }

    function listGroups() {
      var thisComp = proj.activeItem;
      if (!thisComp) {
        alert('No active composition');
        return false;
      }

      group1.remove(listbox1);
      group1.remove(listbox2);
      group1.remove(listbox3);

      var step = Math.max(1, Number(edittext1.text));
      if (step != Number(edittext1.text)) {
        edittext1.text = step;
      }
      var listbox_array = [];
      for (var i = 1; i <= thisComp.numLayers; i += step) {
        listbox_array.push('[' + i + '-' + Math.min(i + step - 1, thisComp.numLayers) + ']');
      }

      listbox1 = group1.add("listbox", undefined, undefined, { items: listbox_array });
      listbox1.preferredSize.width = 80;
      listbox1.preferredSize.height = Math.min(720, listbox_array.length * 22);
      listbox2 = group1.add("listbox", undefined, undefined, { items: ["Move After", "Move Before"] });
      listbox2.selection = 0;
      listbox3 = group1.add("listbox", undefined, undefined, { items: listbox_array });
      listbox3.preferredSize.width = 80;
      listbox3.preferredSize.height = Math.min(720, listbox_array.length * 22);

      palette.layout.layout(true);
    }

    listGroups()
  }
})(this);

 

 

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 ,
Jan 10, 2024 Jan 10, 2024

Copy link to clipboard

Copied

Bonjour Airweb, merci infiniment.

Ca fonctionne mais je me suis sans doute mal exprimé.

Dans l'état ça revient au même avec une manip à la souris, c'est à dire groupe par groupe je change l'ordre.

En fait ce que je souhaiterai c'est que tous les groupes/layers de la compo (imagine une quantité importante)  inverse leur ordre de telle manière le groupe ABC qui sont en haut de la liste des groupe layers donc en index 1. 2 et 3, soient en bas de la liste donc en index 201, 202, et 203 ensuite que DEF en 3, 4, et 5 soient 198, 199, et 200 et ainsi de suite avec tous les groupes/layers mais en une seule manip!

merci

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
Enthusiast ,
Jan 10, 2024 Jan 10, 2024

Copy link to clipboard

Copied

OK, maintenant, c'est clair:

 

screenshot.png

 

 

Reverse_Layers_Order_by_Group.jsx

 

 

(function (thisObj) {
  buildUI(thisObj);

  function buildUI(thisObj) {
    var palette = new Window("palette", "Reverse Layers Order by Group", undefined, { resizeable: true });
    palette.orientation = "column";
    palette.alignChildren = ["center", "top"];
    palette.spacing = 10;
    palette.margins = 10;

    var group1 = palette.add("group");
    group1.orientation = "row";
    group1.alignChildren = ["left", "center"];
    group1.spacing = 10;
    group1.margins = 0;

    var statictext1 = group1.add('statictext', undefined, "GROUP by:");
    var edittext1 = group1.add('edittext', undefined, "3");
    edittext1.preferredSize.width = 50;

    var button1 = palette.add("button");
    button1.text = "REVERSE";

    if (palette instanceof Window) {
      palette.center();
      palette.show();
    } else {
      palette.layout.layout(true);
      palette.layout.resize();
    }

    button1.onClick = function () {
      app.beginUndoGroup("undo");
      var proj = app.project;
      var thisComp = proj.activeItem;
      if(!thisComp){
        alert('No active composition');
        return false;
      }
      var numLayers = thisComp.numLayers;
      var step = Number(edittext1.text);

      for (var i = 1; i < numLayers; i += step) {
        for (var j = i + step; j != i; j--) {
          thisComp.layer(1).moveAfter(thisComp.layer(numLayers - (i - 1)))
        }
      }
      app.endUndoGroup();
    }
  }
})(this);

 

 

 

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 ,
Jan 10, 2024 Jan 10, 2024

Copy link to clipboard

Copied

LATEST

BRAVO ! Merci beaucoup trop fort

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