🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.scripting.indesign
6 messages
6 total messages Started by Lorna_Hadley Wed, 04 Mar 2009 17:26
script request
#810
Author: Lorna_Hadley
Date: Wed, 04 Mar 2009 17:26
3 lines
953 bytes
I am looking, in vain it seems, for a script that will add .125 inches or 0p9 horizontally and vertically from the center of a box. eg., if my box was 2 x 2 inches, I would like the box to end up being 2.125 x 2.125 added from the center of the box. Is this possible and would anyone be interested in making a script that would do this?
Thanks!
Lorna
Re: script request
#814
Author: Kasyan_Servetsky
Date: Wed, 04 Mar 2009 18:33
22 lines
1477 bytes
Hi Lorna,

I assume that one box is selected in the current document. But there is not enough information in your post: which box should be transformed – graphic/text frame, only selected frame or all on the page /spread/ in document etc.

Kasyan



if (app.selection.length > 0) {
   var mySelection = app.selection[0];
}
else {
   alert("Select a box.");
   exit();
}
var myBounds= mySelection.geometricBounds;
var myWidth = myBounds[3] - myBounds[1];
var myHeght = myBounds[2] - myBounds[0];
var myHorScaleFactor = (myWidth + 0.125)/myWidth;
var myVerScaleFactor = (myHeght + 0.125)/myHeght;
var myTransformationMatrix = app.transformationMatrices.add({horizontalScaleFactor:myHorScaleFactor, verticalScaleFactor:myVerScaleFactor});
mySelection.transform(CoordinateSpaces.PASTEBOARD_COORDINATES, AnchorPoint.CENTER_ANCHOR, myTransformationMatrix);
Re: script request
#816
Author: Jeremy_Bowman
Date: Wed, 04 Mar 2009 18:33
39 lines
2015 bytes
Warning: I'm an amateur! But this seems to work for me. Select the box you want to expand, then run the script.



if (app.documents.length > 0){ 
   var myDocument = app.activeDocument; 
   var myViewPreferences = myDocument.viewPreferences; 
   var myOldXUnits = 
myViewPreferences.horizontalMeasurementUnits; 
   var myOldYUnits = myViewPreferences.verticalMeasurementUnits; 
   var myOldRulerOrigin = myViewPreferences.rulerOrigin; 
   myDocument.viewPreferences.horizontalMeasurementUnits 
= MeasurementUnits.points; 
   myDocument.viewPreferences.verticalMeasurementUnits 
= MeasurementUnits.points;

   if (app.selection.length == 1){ 
      var myBox = app.selection[0]; 
      if (myBox.constructor.name == 
"TextFrame" || myBox.constructor.name == "Rectangle"){ 
         myExpand(myBox); 
         } 
      else 
         alert("You 
haven't selected a box as required. Select a box and try again."); 
         }    
      app.activeDocument.viewPreferences.horizontalMeasurementUnits 
= myOldXUnits; 
      app.activeDocument.viewPreferences.verticalMeasurementUnits 
= myOldYUnits; 
      app.activeDocument.viewPreferences.rulerOrigin 
= myOldRulerOrigin; 
   }

function myExpand(myBox) { 
   var myBounds = myBox.geometricBounds; 
   myBox.geometricBounds = [myBounds[0] - 4.5, 
myBounds[1] - 4.5, myBounds[2] + 4.5, myBounds[3]+4.5]; 
   } //end function myExpand
Re: script request
#815
Author: Jeremy_Bowman
Date: Wed, 04 Mar 2009 18:34
1 lines
662 bytes
Ooops! -- Didn't see that your question had already been answered!
Re: script request
#818
Author: Lorna_Hadley
Date: Wed, 04 Mar 2009 19:04
2 lines
885 bytes
OH so sorry! I didn't realize you would need this info (duh!). I would like to expand selected graphic boxes only. We place files in indesign to manually step files for gang runs on our DI and I end up expanding these boxes manually, that's a lot of '+.125' input!
Thanks for your quick responses, you guys are terrific!
Re: script request
#819
Author: Jeremy_Bowman
Date: Wed, 04 Mar 2009 19:31
33 lines
2104 bytes
This version expects you to manually select a bunch of graphic boxes and then run the script:



if (app.documents.length > 0){ 
  var myDocument = app.activeDocument; 
  var myViewPreferences = myDocument.viewPreferences; 
  var myOldXUnits = myViewPreferences.horizontalMeasurementUnits; 
  var myOldYUnits = myViewPreferences.verticalMeasurementUnits; 
  var myOldRulerOrigin = myViewPreferences.rulerOrigin; 
  myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points; 
  myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;

   if (app.selection.length != 0){ 
      myList = app.selection; 
      for (var i = 0; i < myList.length; i++){ 
         var myBox = app.selection[i]; 
         if (myBox.constructor.name == "TextFrame" || myBox.constructor.name == "Rectangle"){ 
         myExpand(myBox); 
         } 
      else 
         alert("The script stopped running because a non-recrangle was selected."); 
        } 
    } 
   app.activeDocument.viewPreferences.horizontalMeasurementUnits = myOldXUnits; 
   app.activeDocument.viewPreferences.verticalMeasurementUnits = myOldYUnits; 
   app.activeDocument.viewPreferences.rulerOrigin = myOldRulerOrigin; 
   }

function myExpand(myBox) { 
  var myBounds = myBox.geometricBounds; 
  myBox.geometricBounds = [myBounds[0] - 4.5, myBounds[1] - 4.5, myBounds[2] + 4.5, myBounds[3] + 4.5]; 
  } //end function myExpand
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads