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

SmartObject Layer Information

New Here ,
Sep 21, 2009 Sep 21, 2009

Hi all,

     I'm creating a util script that will export layer data to a game engine.  Is there any way to get at the transform (position, rotation, scale) of a SmartObject layer?  Photoshop must store this somewhere since smartObject layers remember their rotation etc.

TNKS!

Ram.

TOPICS
Actions and scripting
3.5K
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
Valorous Hero ,
Sep 21, 2009 Sep 21, 2009

You may be out of luck, see this thread....

http://www.ps-scripts.com/bb/viewtopic.php?t=2643

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
Guru ,
Sep 21, 2009 Sep 21, 2009

Xbytor is right. The Smart Object descriptor only has two key. One is for placed type(bitmap or vector) and the other is the filename(no path) of the placed file.

In the GUI you can choose Edit-Transform-Scale with a Smart Object layer and the option bar will have the transform values but I have not been able to work out a way to do this via scripting.

There are quite a few things that do not have scripting access, it looks like this is one.

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
Sep 21, 2009 Sep 21, 2009

The transform includes warps, and possibly rasterization parameters.

Even if that data were provided, it's not likely to be useful.

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
Guru ,
Sep 21, 2009 Sep 21, 2009

I agree that warps throw everything out the window, but I think the transform info would be very useful.

Without that information a script can not know the height and width of the original file so that it can resize a different file to replace that Smart Objects contents and still have the same overall appearance. Without that info if the new file is not the same size as the original placed file, the size changes.

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
Guide ,
Sep 22, 2009 Sep 22, 2009

Micheal, I have NOT done a great deal of scripting with the use of smart objects but find the opposite to be true. If I scale and rotate a smart object then choose to replace that file with one that is both a different size and shape the replaced smart object is transformed to fit the visual bounds of the previous one preserving the appearance or have I just got a whacky install? (CS2 BTW) You can always use script listener to edit the placed file and store its actual size so you could adjust your replacement file to suit?

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
Guru ,
Sep 22, 2009 Sep 22, 2009

Perhaps Adobe changed smart objects since CS2. With CS4 if a smart object is not replaced with the same size file the visual bounds change.

And it's true that if a script did the placement it could store the size for later use. But if the smart object already exists the script can only determine two things from the smart object descriptor -

The type: 'rasterizeContent' or 'vectorData'

And the filename of the placed file if it is a pixel mapped file. If the smart object is a vector even the filename is not stored, 'Vector Smart Object.ai' is always in that key.

The script could also try to get the layer bounds before and after the replace to ensure the same bounds but that becomes difficult if the file was rotated when placed.

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
Guide ,
Sep 22, 2009 Sep 22, 2009

Im probably on the wrong wavelength here as Im using old hat software but I was thinking like this with my poor coding (sorry)

#target photoshop

app.bringToFront();

var docRef = app.activeDocument;

editSmartLayer();

// Edit Smart Layer

function editSmartLayer() {

  function cTID(s) { return app.charIDToTypeID(s); };

  function sTID(s) { return app.stringIDToTypeID(s); };

    var desc01 = new ActionDescriptor();

    executeAction( sTID('placedLayerEditContents'), desc01, DialogModes.NO );

    var soRef = app.activeDocument;

    var soWidth = soRef.width;

    alert( soWidth );

    var soHeight = soRef.height;

    alert( soHeight );

    var soRes = soRef.resolution;

    alert( soRes );

    soRef.close(SaveOptions.DONOTSAVECHANGES)

};

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
Guru ,
Sep 22, 2009 Sep 22, 2009
LATEST

That would work to get the size. But not with vector data. I guess that you could try Bridgetalk to see if it was opened in Illustrator for .ai and .eps files. I'm not sure what app would be used for .pdf

However getting the size was an example of what could be done if the transform info could be determined by a script.

And as far as old hat software goes, I'm still using MS Office 2000

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