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

open as linked smart object

Community Beginner ,
Feb 10, 2015 Feb 10, 2015

Hello,

iam looking for a solution to open files in a folder

and copy then into a document.

Its working good, but i need the files to be linked smart object.

Anyone knows a solution ?

Here my Code so far:

See in line 33. Convert to smart object: ?

var file = new File('C:/User_MY PATH.PSD'),

docRef = open(file);

// Use the path to the application and append the samples folder

var samplesFolder = Folder('C:/USERS_MY FOLDER');

//Get all the files in the folder

var fileList = samplesFolder.getFiles()

  // open each file

  for (var i = 0; i < fileList.length; i++)

  {

  // The fileList is folders and files so open only files

  if (fileListinstanceof File)

  {

  open(fileList)

  // use the document name for the layer name in the merged document

  var activeDocName = app.activeDocument.name;

  var targetDocName = activeDocName.substring(0, activeDocName.lastIndexOf("."));

  // Copy the Document

  app.activeDocument.selection.selectAll()

  //convertToSmartObject(); THIS ISNT WORKING - CONVERT IT ?

  app.activeDocument.selection.copy()

  // don’t save anything we did

  app.activeDocument.close(SaveOptions.DONOTSAVECHANGES)

  //Select specific layer to paste the copy, this is to make sure the layers are in a specific position

  var doc = app.activeDocument;

  doc.activeLayer = doc.artLayers.getByName("bgr");

  //Paste Document

  app.activeDocument.paste()

  app.activeDocument.activeLayer.name = targetDocName

  }

  };

TOPICS
Actions and scripting
1.3K
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

correct answers 1 Correct answer

Community Expert , Feb 10, 2015 Feb 10, 2015

Use scriptlistener:

var idPlc = charIDToTypeID( "Plc " );

    var desc2 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

    desc2.putPath( idnull, new File( "C:\\Photos\\myPhoto.psd" ) );

    var idLnkd = charIDToTypeID( "Lnkd" );

    desc2.putBoolean( idLnkd, true );

    var idFTcs = charIDToTypeID( "FTcs" );

    var idQCSt = charIDToTypeID( "QCSt" );

    var idQcsa = charIDToTypeID( "Qcsa" );

    desc2.putEnumerated( idFTcs, idQCSt, idQcsa );

    var idOfst = charIDToTypeI

...
Translate
Adobe
Community Expert ,
Feb 10, 2015 Feb 10, 2015

Use scriptlistener:

var idPlc = charIDToTypeID( "Plc " );

    var desc2 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

    desc2.putPath( idnull, new File( "C:\\Photos\\myPhoto.psd" ) );

    var idLnkd = charIDToTypeID( "Lnkd" );

    desc2.putBoolean( idLnkd, true );

    var idFTcs = charIDToTypeID( "FTcs" );

    var idQCSt = charIDToTypeID( "QCSt" );

    var idQcsa = charIDToTypeID( "Qcsa" );

    desc2.putEnumerated( idFTcs, idQCSt, idQcsa );

    var idOfst = charIDToTypeID( "Ofst" );

        var desc3 = new ActionDescriptor();

        var idHrzn = charIDToTypeID( "Hrzn" );

        var idPxl = charIDToTypeID( "#Pxl" );

        desc3.putUnitDouble( idHrzn, idPxl, 0.000000 );

        var idVrtc = charIDToTypeID( "Vrtc" );

        var idPxl = charIDToTypeID( "#Pxl" );

        desc3.putUnitDouble( idVrtc, idPxl, 0.000000 );

    var idOfst = charIDToTypeID( "Ofst" );

    desc2.putObject( idOfst, idOfst, desc3 );

executeAction( idPlc, desc2, 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
Community Beginner ,
Feb 12, 2015 Feb 12, 2015

This is working, but i want to read in a whole folder

not a specific file. I have to look into it - thanks 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
Enthusiast ,
Feb 10, 2015 Feb 10, 2015

Also you should be able to use application.open(file, OpenDocumentType.PHOTOSHOP, true) to open a file as a smart object and the duplicate it to your target doc. If you do the same in UI, it should create a linked smart object.

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 Beginner ,
Feb 11, 2015 Feb 11, 2015

Its working for Smart Object - but it didnt convert it to LINKED one.

Also therre is a small Problem, that i copy the selection - i have to copy/duplicate the layer.

Thanks,

Alpha

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
Enthusiast ,
Feb 11, 2015 Feb 11, 2015

You are right, it's not linked even if you use "File->Open as Smart Object".. Doesn't seem to be a way in API to create linked ones

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 ,
Feb 11, 2015 Feb 11, 2015

Using the scriptlistener as I mentioned above works fine to place a file as a linked SO. Just replace the file name with a variable in line 4.

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 ,
Feb 12, 2015 Feb 12, 2015

Yes, that's why you put the scriptlistener code in a function and send that function a variable with each of the file's paths from the folder.

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 Beginner ,
Feb 12, 2015 Feb 12, 2015

thanks - thats it

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
New Here ,
Nov 18, 2015 Nov 18, 2015
LATEST

Hi there,

It but it would be very useful to me too.

As I'm not familiar with scripting in photoshop, I have hard time to read the code, especially the one Chuck Uebele posted, as it looks less beginner friendly than the Alphavader posted in the first place.

My question is : Is there anyone that finalize the script ? (preferably with comments in the code...)

Thanks for reading  !

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