Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


convert to smart object

Explorer ,
Aug 31, 2021 Aug 31, 2021

Copy link to clipboard

Copied

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?

hui5C21_0-1630461652860.png

Thanks very much if someone can give a clue.

best wishes!

TOPICS
Actions and scripting

Views

91

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 31, 2021 Aug 31, 2021

Copy link to clipboard

Copied

Wrong topic ...

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Sep 03, 2021 Sep 03, 2021

Copy link to clipboard

Copied

Tell us the correct name of topic for this thread.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 31, 2021 Aug 31, 2021

Copy link to clipboard

Copied

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 );
}

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 01, 2021 Sep 01, 2021

Copy link to clipboard

Copied

weird,some error occured, said invalid paramaters

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 31, 2021 Aug 31, 2021

Copy link to clipboard

Copied

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;

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 01, 2021 Sep 01, 2021

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Sep 01, 2021 Sep 01, 2021

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Sep 01, 2021 Sep 01, 2021

Copy link to clipboard

Copied

Reset preferences and try again.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 09, 2021 Sep 09, 2021

Copy link to clipboard

Copied

LATEST

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines