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

Snapping objects to each other after SSR effect

Enthusiast ,
Aug 19, 2018 Aug 19, 2018

Hey guys, I've made an SSR GUI:

NimbleSparseArgentineruddyduck-size_restricted.gif

That can apply a scale-shear-rotate effect and also write/read pageItem.tags for orientation:

FineHandsomeIndigobunting-size_restricted.gif

It can recognize the existence of pre-existing or multiple tags/orientations in the current selection:

PowerfulInsignificantAustralianshelduck-size_restricted.gif

So that finally, I might be able to work with a "scrunch" or assemble feature that tries to guess how the pieces slot together and fit. I'd made a scrunch align for another panel but it was based on the bounding box rects of each and I don't think that would work here, especially with steeper angles. I'm trying to work out the logic of how I should approach this, if I wanted to draw a cube and click on the menu's center to snap the objects in place instead of positioning them manually here:

ObedientIncompatibleFlicker-size_restricted.gif

This seems possible, but I don't know how to approach it especially for any conceivable shape and not only rectangles. Is there any easy way of doing this? I saw talk of using app.executeMenuCommand('SelectionHat5') for hitbox and touching art​​ but I tried it and don't get how it works. Nimbling on github wanted to revamp their original scripts for this, so I refactored them into a single function:

var thisDoc = app.documents[0];

var exist = app.documents.length > 0;

var hasPath = thisDoc.pathItems.length > 0;

// SSR(-30, 'Top')

// SSR(30, 'Top')

// SSR(-30, 'Right')

// SSR(30, 'Right')

// SSR(-30, 'Left')

// SSR(30, 'Left')

function SSR(ang, direction){

  if (exist && hasPath) {

    for (i = 0; i < thisDoc.selection.length; i++) {

      calcSSR(ang, direction, thisDoc.selection);

    }

  }

}

function calcSSR(ang, direction, selectedObject) {

  // Scale

  AngToRad = toRadians(ang);

  scale2 = Math.cos(AngToRad) * 100;

  selectedObject.resize(100, scale2);

  // Shear

  var im = app.getIdentityMatrix();

  if (direction == 'Top')

    DeltaAngToRad = toRadians(-ang);

  else

    DeltaAngToRad = toRadians(ang);

  im.mValueC = Math.tan(DeltaAngToRad);

  selectedObject.transform(im, true, true, true, true, 1, undefined);

  // Rotate

  if ((direction == 'Right') && (ang < 0))

    selectedObject.rotate(3 * ang);

  else if ((direction == 'Left') && (ang > 0))

    selectedObject.rotate(3 * ang);

  else

    selectedObject.rotate(ang);

  return selectedObject;

}

function toDegrees(angle) {

    return angle * (180 / Math.PI);

}

function toRadians(angle) {

    return angle * (Math.PI / 180);

}

The tagging is done separately but I could probably record more data as additional tags like the original pageItem rotation or transform values, etc. Any pointers or ideas?

TOPICS
Scripting
1.0K
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
Adobe
Advocate ,
Aug 21, 2018 Aug 21, 2018

Salut !

Tu veux réaliser ce genre de travail ?

avec 3 objets 1 2 3, je lance le script 3 fois.

rotate.PNG 

var j = "0";

    j = prompt("Mode ? 0-5",j,"");

switch (j) {

      case ("0"): SSR(-30, 'Top'); break;

      case ("1"): SSR(30, 'Top'); break;

      case ("2"): SSR(-30, 'Right'); break;

      case ("3"): SSR(30, 'Right'); break;

      case ("4"): SSR(-30, 'Left');break;

      case ("5"): SSR(30, 'Left');

      }

De LR

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 21, 2018 Aug 21, 2018

Désolé, je ne parle pas français! Est-ce que Google traduit bien?

prompt('Mode ? 0-5',j,'')

^ Très cool! Je n'en savais rien.

Je voudrais un bouton supplémentaire qui assemblera les morceaux:

FaintWhoppingDogfish-size_restricted.gif

Il devrait connaître l'orientation à cause de app.documents[0].pageItem.tag, puis déplacer les objets en fonction de l'orientation. Pensez-vous que c'est possible?

Voici le script complet avec fonction de tagging si vous êtes curieux.

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
Advocate ,
Aug 22, 2018 Aug 22, 2018

Salut !

Tout est possible, moi, j'ai utilisé seulement des noms Top Left Right est ZOrderMethod

if (obj.name == "Top") {

Je me suis intéressé seulement aux modes 0 2 5, c'est juste une approche par curiosité,

l'objet de base étant Top.

rotate3.png

Il serait important pour moi de connaître le but exact du script (pour faire quoi exactement ?)

Mes coordonnées sont sous la photo de profil.

De elleere

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 22, 2018 Aug 22, 2018

La base étant en haut n'est que dans le prototype - il suffit de tester les choses pour le moment.

renél80416020  wrote

Il serait important pour moi de connaître le but exact du script (pour faire quoi exactement ?)

Ma propre vanité! Vraiment. Aucun but ou besoin exact, juste pour le plaisir, quelqu'un a demandé une interface utilisateur pour gérer les fonctions SSR (Scale-Shear-Rotate). Je pensais qu'il fallait justifier d'être un panel, au lieu d'une action connectée via un raccourci clavier ou l'exécution d'un script via un raccourci clavier.

J'ai pensé qu'il serait peut-être temps de regrouper ou d'assembler des objets après cela et de gagner du temps en déplaçant leurs nouvelles positions.

Etes-vous sûr que vos coordonnées sont en dessous de la photo de profil? Lol

Donc, je pourrais le faire avec des rectangles sans problème. Il vous suffit de trouver les points médians, de pousser tous les objets les uns contre les autres en fonction des limites de la boîte de sélection et des points médians, mais ce n’est pas si facile lorsque les objets sont obtus ou dessinés au stylet. C'est pourquoi je suis curieux de savoir s'il existe une sorte de détection de collision, de hitbox, de détection de chevauchement, etc.

Illustrator a clairement la détection de collision avec Pathfinder, Live Paint et Shape Builder. Il existe un moyen de vérifier que les formes se chevauchent, sinon ces outils ne fonctionneraient pas - mais comment cela fonctionne-t-il et si cela peut être fait via des scripts ... Pas sûr.

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
Advocate ,
Aug 30, 2018 Aug 30, 2018

Bonjour Off Topic,

J'ai réalisé un script à partir de ton idée, il place les trois faces de la perspective angles 10 30 40°

Je traite 3 images directement (tracés, groupe, tracé transparent, image bitMap, etc.

Si tu aimes la perspective isométrique voilà un aperçu (à partir de 3 carrés angle 30°)

les mosaïques sont réalisées par un script de ma conception.

les couleurs sont aléatoires à l'intérieur d'une plage dans le nuancier.

Le Cloud d'Orange

Ps
Tu n(as pas répondu à mon mail ?

LR

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 30, 2018 Aug 30, 2018
LATEST

Hello! Sorry, I did not send the email, I did not have an example to provide. Someone else wanted me to build a panel / UI for this and provided me with part of that script, so I expanded it but didn't know exactly how they'd use it. I plan on rebuilding the UI from the ground up and was planning to get back to you at that point. Also with your script, coooooool! lol

How are you doing the positioning for these mosaics? Any form of collision detection, or is it through the bounding box? I saw an example using Pathfinder by Ten Here, but I get two error messages in trying. I was planning to try and use that route but found LiveXMLEffect doesn't work the same and doesn't detect collisions. How did you do the 10 and 40 also? I tried to make it all together but that became confusing. Is your script anything like this one ?

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