Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Resize graphic frames with an Object style applied

Return to Member Forum

  • Author
    Posts
    • #60576
      Anonymous
      Inactive

      Hi all

      My scripting's not great, hoping someone can help?

      I need to search my document for graphic frames that have the Object style 'CarImage' applied and resize those frames to 26mm wide by 13mm high (using top left as the reference). I don't need to scale the content, just resize the frames.

      All help much appreciated.

      Mike

    • #60577
      David Blatner
      Keymaster

      This isn't exactly the same, but check out the tomaxxiResizeEach script:

      https://tomaxxi.com/downloads/

    • #60579
      Anonymous
      Inactive

      Thanks David – that's cool but not quite it. It's a doc of over 100pp – I can find all the objects I need and apply an object style to them, but can't then resize them. (It's a template change of a long doc to a new page size).

      Cheers

      Mike

    • #60613

      Main();

      function Main() {
      if (app.documents.length > 0) {
      var doc = app.activeDocument;
      var objStyle = doc.objectStyles.item(“CarImage”);
      if (objStyle.isValid) {
      doc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.MILLIMETERS;
      doc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.MILLIMETERS;

      var objPref = app.findObjectPreferences;
      objPref.appliedObjectStyles = objStyle;
      var found = doc.findObject();

      for (var i = 0; i < found.length; i++) {
      frame = found[i];
      gb = frame.geometricBounds;
      gb_new = [ gb[0], gb[1], gb[0]+13, gb[1]+26 ];
      frame.geometricBounds = gb_new;
      }
      }
      else {
      alert(“Object style “CarImage” doesn't exist”);
      }
      }
      else {
      alert(“No open documents.”);
      }
      }

    • #60614

      Forgot to add var in the following lines:

      var frame = found[i];
      var gb = frame.geometricBounds;
      var gb_new = [ gb[0], gb[1], gb[0]+13, gb[1]+26 ];

    • #60615

      Oops! My fingers work faster than my brain. Unfortunately I can't edit the post!

      Here's a new version:

      Main();

      function Main() {
      var frame, gb, gb_new;
      if (app.documents.length > 0) {
      var doc = app.activeDocument;
      var objStyle = doc.objectStyles.item(“CarImage”);
      if (objStyle.isValid) {
      doc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.MILLIMETERS;
      doc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.MILLIMETERS;

      var objPref = app.findObjectPreferences;
      objPref.appliedObjectStyles = objStyle;
      var found = doc.findObject();

      for (var i = 0; i < found.length; i++) {
      frame = found[i];
      gb = frame.geometricBounds;
      gb_new = [ gb[0], gb[1], gb[0]+13, gb[1]+26 ];
      frame.geometricBounds = gb_new;
      }
      }
      else {
      alert(“Object style “CarImage” doesn't exist”);
      }
      }
      else {
      alert(“No open documents.”);
      }
      }

    • #60618
      David Blatner
      Keymaster

      Thanks, Kasyan! Cool. Sorry… we are working on a new forum and site software, and one of the things we will definitely try to do is allow people to edit their own posts!

    • #60619

      Hi Dave,

      I have a suggestion: the new forum software should provide for possibility to post code. In the code I posted, backslashes have been removed before the quotes surrounding the CarImage in the line 24, which will result in error in case the object style doesn't exist in the document.

      The line should have been be like so:

      alert(“Object style [backslash]“CarImage[backslash]” doesn't exist”);

      Formerly I tried to enclose the code in

      tag in the HTML source editor, but this didn't help.

      Regards,
      Kasyan

    • #60624
      Anonymous
      Inactive

      Hi Kasyan, thanks for your help on this.

      It's giving me:

      Error Number: 55

      Error String: Object does not support the property or method 'isValid'

      Line: 8

      Source: if (objStyle.isValid) {

      Make any sense?

      Mike

    • #60626

      Hi Mike,

      What version of InDesign are you on? I guess you're on CS3.

      It's always a good idea to specify the InDesign version and the platform — Mac or PC — for which you want the script.

      Let's try to replace

      if (objStyle.isValid) {

      with

      if (objStyle != null) {

      to make it compatible with CS3.

      Regards,
      Kasyan

    • #60627
      Anonymous
      Inactive

      Genius, that works a charm – great script.

      Thanks a million for taking time to help and will be sure to include version number next time.

      Cheers my friend

      Mike

    • #60656
      Chuck Nigash
      Member

      This is a pretty good thread. And another reason why — maybe with our new ID Secrets website coming — we should have an ID wishlist portal.

      Because if Adobe's listening here … Object Styles should also contain geometry that include X,Y position, proxy & X,Y proportion, maybe even scaling percentage would be nice.

      Talk about efficiency. This is a cross-court winner. Obj Styles could contain it, but even BETTER would be Object Tags in which values relating to print & digital media are tagged & controlled by the text frame attributes themselves.

      As InDesign begins to merge print with digital platform export, there are huge advantages here.

      2 cents …

    • #61139
      Anonymous
      Inactive

      Hi Kasyan

      Thanks again for sorting this – I had it working, but now when I run it it seems to do nothing – code below. Any thoughts at all? All help appreciated. Running InDesign CS3.

      Mike

      Main();

      function Main() {
      var frame, gb, gb_new;
      if (app.documents.length > 0) {
      var doc = app.activeDocument;
      var objStyle = doc.objectStyles.item(“Review Pic Box Stroked”);
      if (objStyle != null) {
      doc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.MILLIMETERS;
      doc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.MILLIMETERS;

      var objPref = app.findObjectPreferences;
      objPref.appliedObjectStyles = objStyle;
      var found = doc.findObject();

      for (var i = 0; i < found.length; i++) {
      frame = found[i];
      gb = frame.geometricBounds;
      gb_new = [ gb[0], gb[1], gb[0]+39.25, gb[1]+24 ];
      frame.geometricBounds = gb_new;
      }
      }
      else {
      alert(“Object style “Review Pic Box Stroked” doesn't exist”);
      }
      }
      else {
      alert(“No open documents.”);
      }
      }

    • #61147

      Hi Mike,

      Try to add this line:

      app.findChangeObjectOptions.objectType = ObjectTypes.GRAPHIC_FRAMES_TYPE;

      It corresponds to the “Type: Graphic Frame” option in the “Object” tab of the “Fing/Change” dialog box. Most probably it is set to a wrong type e.g. “Text Frame” at the moment and the script finds nothing.

      Hope this helps.

      Kasyan

    • #61148
      Anonymous
      Inactive

      You're a lifesaver, thanks Kasyan.

      If you ever need Filemaker Pro help, please do shout.

      All the best

      Mike

    • #62060
      Chuck Nigash
      Member

      A twist down memory lane on this.

      Can this script be modified to specify layer and scale the layer's elements by percentage?

Viewing 15 reply threads
  • You must be logged in to reply to this topic.
Forum Ads