Skip to main content
Known Participant
November 8, 2024
Question

a script that detects whether an object is turned 180 degrees

  • November 8, 2024
  • 2 replies
  • 2227 views

hello!
I have a question as in the subject, is it possible to create a script that will be able to distinguish two objects, or groups of objects, if one is turned 180 degrees relative to the other?

In the case of objects different from each other there is no problem, it checks its dimension and when they are different the script knows that they are different objects, but I have a problem in the case when the objects are the same size, but are turned 180 degrees, their size is the same.

Does anyone know how to do this? I even tried to ask openAI, it seemed to write something but in none of the cases was the script able to distinguish this
matrix does not work

sorry for my English, it is basic
please help

This topic has been closed for replies.

2 replies

m1b
Community Expert
Community Expert
November 8, 2024

Hi @Majonezowy, it would be good if you can post some demo document with an example of an easy comparison, a "middle difficulty" comparison and "the hardest conceivable" comparison.

 

I think that the hardest conceivable comparison might be simply a 180° rotated, embedded, raster item that has no BBAccumRotation tag.

 

That case might actually be challenging.

- Mark

Known Participant
November 8, 2024

I once created a script to insert registration marks into objects. In registration marks each object is numbered. this script is able to distinguish whether an element is the same or not based on its size. When an element is the same but is turned 90 degrees, its size is different (X swapped with Y), so the script knows that these are different elements. I want it to be the same when the object is turned 180 degrees (the script must distinguish these elements not by their size because after turning 180 the size is the same)

renél80416020
Inspiring
November 9, 2024

Bonjour @Majonezowy 

Quel est le type de cet objet?

Vous voulez un script spécifique à cet objet?

C'est vous qui les mettez en place dans Illustrator ou cela est déja fait à l'origine?

 

S'il s'agit d'un groupe:

1 la balise n'est pas créée automatiquement après rotation.

2 il faut se baser sur la position de l'un des éléments du groupe par rapport à la position du groupe [top,left]

René

 

renél80416020
Inspiring
November 8, 2024

Bonjour,

Le Tag nommé BBAccumRotation, si rotation il y a donne l'angle de rotation.

Si pas de rotation, ce Tag n'existe pas, si il existe sa valeur indique 0°.  

Pour 180°

Tag: (BBAccumRotation , 180.000019847843)

 

Remarque importante:

Pour que ce script fonctionne, il ne faut pas que l'objet sélectionné ai subit une rotation par script sauf si le script a mis à jour la valeur de ce Tag (Qui est chose rare).

 

 

// Find tags of selected art item, show names and values in separate document
// tags.js de elleere
// 05 02 2018
if ( app.documents.length > 0 ) {
  doc = app.activeDocument;
if ( doc.selection.length > 0 ) {
  sel = selection;
  for ( i = 0; i < sel.length; i++ ) {
    selectedArt = sel[i];
    type = selectedArt.typename;
    tagList = selectedArt.tags;
      if (tagList.length == 0) {
        alert( type+"\rThe selected art has no tags" );
      }
      else { // Create a document and add a line of text per tag
        reportDocument = app.documents.add();
        top_offset = 400;
        newItem = reportDocument.textFrames.add();
        newItem.contents = type+"\r";
        newItem.position = [100, top_offset];
          for ( k = 0; k < tagList.length; k++ ) {
            tagText = tagList[k].value* 180 / Math.PI;
            newItem.contents += "Tag: (" + tagList[k].name +
            " , " + tagText + ")\r";
          }
      }
  }
}
else { alert( "No art items selected." ); }
}

 

 

 

René

Known Participant
November 8, 2024

I didn't know about tags, good method, but unfortunately it won't be useful for me. I work on files saved outside of Illustrator, so objects unfortunately don't have tags saved.