• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

280

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
Explorer ,
Aug 31, 2021 Aug 31, 2021

Copy link to clipboard

Copied

Wrong topic ...

Votes

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
LEGEND ,
Sep 03, 2021 Sep 03, 2021

Copy link to clipboard

Copied

Tell us the correct name of topic for this thread.

Votes

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
Community Expert ,
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 );
}

 

Votes

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

Votes

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
Community Expert ,
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;

Votes

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

Votes

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
Community Expert ,
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.

Votes

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
LEGEND ,
Sep 01, 2021 Sep 01, 2021

Copy link to clipboard

Copied

Reset preferences and try again.

Votes

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.

Votes

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