3 Replies Latest reply on Feb 21, 2013 4:07 AM by Damienned

    Determining a KEY object in a selection via JavaScript

    mrjackgill

      Is there a way to determine which object in a selection is the key object? For example: draw 10 squares on a layer, select all of them, click on one of the 10 and it becomes the Key Object (heavy border) for things like Distribute Spacing on the Align pallete. I can determine that a particular object is selected via ActiveDocument.Selection.PathItem[n].Selected = true/false. But I can't figure out how to find out if this is the KeyObject. Maybe I'm looking in the wrong place?  Thank you.  The ultimate goal is to modify the below script so that it uses the KeyObject as the reference and not the object on the bottom-most layer.

       

      Here is the Script - from http://illustrator.hilfdirselbst.ch/dokuwiki/en/skripte/javascript/width_and_height

       

      mySelection = activeDocument.selection;

      if (mySelection.length>0){

      if (mySelection instanceof Array) {

      goal=mySelection[mySelection.length-1];

      for (i=0; i<(mySelection.length-1); i++){

        ratioW = 100/(mySelection[i].width/goal.width);

        ratioH = 100/(mySelection[i].height/goal.height);

        mySelection[i].resize(ratioW,ratioH)

      }

      }

      }else{

      alert("Nothing selected!")

      }

       

       

      Thank You!!