Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all articles
Browse latest Browse all 12845

PARM error (shows as mrap) with multiple selections, no error with single selection

$
0
0

Hello all,

I am new to Illustrator scripting this is my first script. I am getting a this error " Error 1200: an Illustrator error occurred: 1346458189 ('MRAP'): line 50" which is the line:

var next_board = doc.artboards.add([next_board_L, next_board_T, next_board_R, next_board_B]);  

It only occurs when I have multiple selections and never when I have only one selection. After a little research I have found the error is actually PARM, but I don't see any uninstantiated variables or other  issues that could be throwing this error. I am on a mac Illustrator CC. I would appreciate any help on the matter. Below is the full script.

#target Illustrator


// This script was made to take all selected objects
// Create a new arboard for all Selected objects
// At a user specified width and height then
// Scale the object to the artboard size and center




var doc = app.activeDocument;
var select = doc.selection;




if (select.length > 0) {     var title = "Fit Selected Object(s) to Artboard(s)";     var msg = "Enter the width and height of artboards (single number)";     var board = Number(Window.prompt (msg, 0, title));         for(var i = 0; i < select.length; i++) {          var selectW = select[i].width;          var selectH = select[i].height;          if(selectH >= selectW) {               if(board > selectH) {                    scale = board/selectH*100;               }          } else {               scale = board/selectW*100;          }          var boardIdx = doc.artboards.getActiveArtboardIndex();          var boardSrc = doc.artboards[boardIdx];          var boardSrc_L = boardSrc.artboardRect[0];          var boardSrc_T = boardSrc.artboardRect[1];          var boardSrc_R = board;          var boardSrc_B = -board;          var moveX = 10;          var next_board_L = boardSrc_R + moveX;           var next_board_T = boardSrc_T;           var next_board_R = next_board_L + (boardSrc_R - boardSrc_L);           var next_board_B = boardSrc_B;          var next_board = doc.artboards.add([next_board_L, next_board_T, next_board_R, next_board_B]);           select[i].resize(              scale, //this is a percentage of current width               scale, //this is a percentage of current height               true, // changePositions               true, // changeFillPatterns               true, // changeFillGradients               true, // changeStrokePattern          );          var selPosX = select[i].left;          var selPosY = select[i].top;                   var selBoardDiffX = next_board_L - selPosX;          var selBoardDiffY = next_board_T - selPosY;          var toCenter = 0;         select[i].translate (                   selBoardDiffX,                   selBoardDiffY,                   true,                   true,                   true,                   true         );         var boardH = next_board.artboardRect[2] - next_board.artboardRect[0];          var boardW = next_board.artboardRect[3] - next_board.artboardRect[1];         if( boardH > select[i].height ) {              toCenter = (boardH-select[i].height)/2;                  select[i].translate (                            0,                            -toCenter,                            true,                            true,                            true,                            true                  );         }         var NegSelectW = select[i].width * -1; //Must be a negative number         if ( boardW < NegSelectW ) {              toCenter = (boardW+select[i].width)/2;                  select[i].translate (                            -toCenter,                            0,                            true,                            true,                            true,                            true                  );         }         }


}

Viewing all articles
Browse latest Browse all 12845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>