4 Replies Latest reply on May 26, 2008 6:23 AM by (P._Marlowe)

    Break Link with Style

      Hello all,

      I need to break a link to an object style via script. I found this discussion:
      http://www.adobeforums.com/webx?128@@.59b4d4d7

      jxswm suggests the line founds[i].applyObjectStyle(dstStyle, false, false); but this is the same as clicking on "None" and not the same as calling "Break link to style". I.e. the formatiing is lost and replaced by [None].

      Has anyone found out how to break the link without the object changing its formatting?

      Thank you very much.
        • 1. Re: Break Link with Style
          Level 1
          How about this approach? I started by creating a pageItem and giving it a new object style. Then I selected the object and ran this script:

          myObj= app.selection[0];
          myStyle = myObj.appliedObjectStyle;
          myTempStyle = myStyle.duplicate();
          myObj.appliedObjectStyle = myTempStyle;
          myTempStyle.remove();

          Dave
          • 2. Re: Break Link with Style
            Level 1
            Very interesting idea. Thank you Dave.
            I'll give it a try today
            • 3. Re: Break Link with Style
              Level 1
              Thanks again, works like a charm. :)
              • 4. Re: Break Link with Style
                Level 1
                Ah, not quite. "myObj.appliedObjectStyle = myTempStyle" removes overrides. But myObj.applyObjectStyle(mytempStyle, false false) does not, so this is easily fixed.

                For any lurkers or archive-diggers (like myself ;) ) my entire routine:


                  var myMenuAction = app.menuActions.item("$ID/Copy");
                  app.clearOverridesWhenApplyingStyle = false;
                  if (app.selection.length > 0) {
                    var noStyle = app.documents[0].objectStyles[0];
                    for (var n=0; n < app.selection.length; n++) {
                      var myObj= app.selection[n];
                      var myStyle = myObj.appliedObjectStyle;
                      if (myStyle != noStyle) {
                        var myTempStyle = myStyle.duplicate();
                        myObj.applyObjectStyle(myTempStyle, false, false);
                        myTempStyle.remove();
                      }
                    }
                  } else {
                    beep();
                    beep();
                  }
                  app.copy();