Skip to main content
Participant
January 9, 2025
Answered

Illustrator error occurred: 1346458189 ('MRAP')

  • January 9, 2025
  • 1 reply
  • 377 views

Getting this error when trying to `applyEffect` free distort

var effectString =
          '<LiveEffect name="Adobe FreeDistort"><Dict data="DistortTopLeftX 0 DistortTopLeftY 0 DistortTopRightX 50 DistortTopRightY -20  DistortBottomLeftX -10 DistortBottomLeftY 70 DistortBottomRightX 60 DistortBottomRightY 50"/></LiveEffect>';
        item.applyEffect(effectString);

The problem seems to be caused by the application of the live effect, as the code worked with a simple effect applied, and I'm applying it to a simple PathItem.

 

While searching it seems like the error is a vague one, so any help would be appreciated

Correct answer sttk3
  • The name and number of arguments for Free Distort were incorrect
  • I expect the number you intended to use is the scale factor, although a percentage will also work
/**
  * @File Free Distort Sample
  * https://community.adobe.com/t5/illustrator-discussions/illustrator-error-occurred-1346458189-mrap/td-p/15079479
  * @3653945.0.0
  * @7111211 sttk3.com
*/

(function() {
  if(app.documents.length <= 0) {return ;}
  var doc = app.documents[0] ;
  var sel = doc.selection ;
  if(sel.length <= 0) {return ;}

  var topLeft = [0, 0] ;
  var topRight = [5, -2] ;
  var bottomLeft = [-1, 7] ;
  var bottomRight = [6, 5] ;

  var effectString = '<LiveEffect name="Adobe Free Distort"><Dict data="R src0h 0 R src0v 0 R src1h 1 R src1v 0 R src2h 0 R src2v -1 R src3h 1 R src3v -1 R dst0h ' + topLeft[0] + ' R dst0v ' + topLeft[1] + ' R dst1h ' + topRight[0] + ' R dst1v ' + topRight[1] + ' R dst2h ' + bottomLeft[0] + ' R dst2v ' + bottomLeft[1] + ' R dst3h ' + bottomRight[0] + ' R dst3v ' + bottomRight[1] + ' "/></LiveEffect>' ;
  
  var targetItem = sel[0] ;
  targetItem.applyEffect(effectString) ;
})() ;

1 reply

sttk3Correct answer
Legend
January 10, 2025
  • The name and number of arguments for Free Distort were incorrect
  • I expect the number you intended to use is the scale factor, although a percentage will also work
/**
  * @File Free Distort Sample
  * https://community.adobe.com/t5/illustrator-discussions/illustrator-error-occurred-1346458189-mrap/td-p/15079479
  * @3653945.0.0
  * @7111211 sttk3.com
*/

(function() {
  if(app.documents.length <= 0) {return ;}
  var doc = app.documents[0] ;
  var sel = doc.selection ;
  if(sel.length <= 0) {return ;}

  var topLeft = [0, 0] ;
  var topRight = [5, -2] ;
  var bottomLeft = [-1, 7] ;
  var bottomRight = [6, 5] ;

  var effectString = '<LiveEffect name="Adobe Free Distort"><Dict data="R src0h 0 R src0v 0 R src1h 1 R src1v 0 R src2h 0 R src2v -1 R src3h 1 R src3v -1 R dst0h ' + topLeft[0] + ' R dst0v ' + topLeft[1] + ' R dst1h ' + topRight[0] + ' R dst1v ' + topRight[1] + ' R dst2h ' + bottomLeft[0] + ' R dst2v ' + bottomLeft[1] + ' R dst3h ' + bottomRight[0] + ' R dst3v ' + bottomRight[1] + ' "/></LiveEffect>' ;
  
  var targetItem = sel[0] ;
  targetItem.applyEffect(effectString) ;
})() ;
Participant
January 10, 2025

Thank you 🙏 this worked