Skip to main content
Known Participant
September 1, 2021
Question

convert to smart object

  • September 1, 2021
  • 5 replies
  • 363 views

Hi~

 I use method 'doc.trim(TrimType.TRANSPARENT)' to trim the activelayer, but it popout confirm panel which i want to skip with default 'OK' button clicked.what should i do?

Thanks very much if someone can give a clue.

best wishes!

This topic has been closed for replies.

5 replies

hui5C21Author
Known Participant
September 9, 2021

I think i got why this happed. When i filter layers empty or background, and undo last trim,this window stop to pop up.

Kukurykus
Legend
September 1, 2021

Reset preferences and try again.

Stephen Marsh
Community Expert
Community Expert
September 1, 2021

You may also need to globally suppress dialogs:

 

// Save the current dialog display settings
var savedDisplayDialogs = app.displayDialogs;
// Turn off the dialogs
app.displayDialogs = DialogModes.NO;

// Do your stuff…

// Restore the dialogs
app.displayDialogs = savedDisplayDialogs;
hui5C21Author
Known Participant
September 1, 2021

When i set this value ,error occured with msg: invalid paramaters

Stephen Marsh
Community Expert
Community Expert
September 1, 2021

I'm not sure why you are getting a pop-up, or why you are getting errors.

 

You could always install Scripting Listener on your computer and see if you get different results.

Stephen Marsh
Community Expert
Community Expert
September 1, 2021

I don't get that message with:

 

app.activeDocument.trim(TrimType.TRANSPARENT); 

 

You could try this raw Script Listener code:

 

var idtrim = stringIDToTypeID( "trim" );
    var desc856 = new ActionDescriptor();
    var idtrimBasedOn = stringIDToTypeID( "trimBasedOn" );
    var idtrimBasedOn = stringIDToTypeID( "trimBasedOn" );
    var idtransparency = stringIDToTypeID( "transparency" );
    desc856.putEnumerated( idtrimBasedOn, idtrimBasedOn, idtransparency );
    var idtop = stringIDToTypeID( "top" );
    desc856.putBoolean( idtop, true );
    var idbottom = stringIDToTypeID( "bottom" );
    desc856.putBoolean( idbottom, true );
    var idleft = stringIDToTypeID( "left" );
    desc856.putBoolean( idleft, true );
    var idright = stringIDToTypeID( "right" );
    desc856.putBoolean( idright, true );
executeAction( idtrim, desc856, DialogModes.NO );

 

Or the same code as a function if you need to use it multiple times:

 

trimTransparency();

function trimTransparency() {
	var s2t = function (s) {
		return app.stringIDToTypeID(s);
	};
	var descriptor = new ActionDescriptor();
	descriptor.putEnumerated( s2t( "trimBasedOn" ), s2t( "trimBasedOn" ), s2t( "transparency" ));
	descriptor.putBoolean( s2t( "top" ), true );
	descriptor.putBoolean( s2t( "bottom" ), true );
	descriptor.putBoolean( s2t( "left" ), true );
	descriptor.putBoolean( s2t( "right" ), true );
	executeAction( s2t( "trim" ), descriptor, DialogModes.NO );
}

 

hui5C21Author
Known Participant
September 1, 2021

weird,some error occured, said invalid paramaters

hui5C21Author
Known Participant
September 1, 2021

Wrong topic ...

Kukurykus
Legend
September 3, 2021

Tell us the correct name of topic for this thread.