1 Reply Latest reply on Apr 26, 2012 6:28 AM by Muppet Mark

    Place/include vector path

    $mm

      Hi Scripters,

       

      I need to place or include a .ai or .eps vector into InDesign with javascript.

      Normal placing isn't the right way, because I need to change the color after placing/including.

       

      How to get the vector path into InDesign with javascript like I would copy the path from Illustrator to InDesign?

        • 1. Re: Place/include vector path
          Muppet Mark Level 5

          The rough n dirty way would be to make use of the pasteboard… Using app.copy() in AI & app.paste() in ID You can most likely read that array of point info and recreate a shape… But this brings color fills and strokes too… I did it to work with an open AI document and the one selected path item… Else it should do nothing… hum might try a bit of that nothing…

           

          #target indesign
          
          indesignMain();
          
          function indesignMain() {
              if ( app.documents.length == 0 ) { return; }
              var script, res;
              script = illustratorCopy;
              script += '\rillustratorCopy();';
              res = btMessaging( 'illustrator', script );
              app.activate();
              if ( res == 'true' ) { app.paste(); }
          };
          
          
          function btMessaging( targetApp, script ) {
              var bt, res;
              bt = new BridgeTalk();
              bt.target = targetApp;
              bt.body = script;
              bt.onResult = function( inBT ) { res = inBT.body; }
              //bt.onError = function( inBT ) {}
              bt.send( 5 );
              return res;
          }
          
          function illustratorCopy() {
              if ( app.documents.length == 0 ) { return false; }
              var doc, sel, uIL;
              uIL = app.userInteractionLevel;
              doc = app.activeDocument, sel = doc.selection;
              if ( sel.length == 1 && sel[0].typename == 'PathItem' ) {
                  app.copy();
                  return true;
              } else {
                  return false;
               }
              app.userInteractionLevel = uIL;
          };