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

convert to smart object

Explorer ,
Aug 31, 2021 Aug 31, 2021

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
359
Translate
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

Wrong topic ...

Translate
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

Tell us the correct name of topic for this thread.

Translate
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

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

 

Translate
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

weird,some error occured, said invalid paramaters

Translate
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

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;
Translate
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

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

Translate
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

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.

Translate
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

Reset preferences and try again.

Translate
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
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.

Translate
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