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

Can files be loaded into a stack in the active document?

Engaged ,
Oct 21, 2018 Oct 21, 2018

I've created a new script based on Load Files into Stack.jsx that adds some sorting and setting functionality to it. The original script creates a new document to load the files into. I'd like to modify it to load them into the active document. Can this be done without modifying the core files it depends on?

Thanks!

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

Contributor , Oct 21, 2018 Oct 21, 2018

I managed to create a workaround for the issue.

Not perfect, but it works and I was only playing, I am sure you can tweak it further:

// (c) Copyright 2006.  Adobe Systems, Incorporated.  All rights reserved.

var currentDoc = app.activeDocument;

/*

@@@BUILDINFO@@@ Load Files into Stack.jsx 1.0.0.1

*/

//

// Load Files into Stack.jsx - does just that.

//

/*

// BEGIN__HARVEST_EXCEPTION_ZSTRING

<javascriptresource>

<name>$$$/JavaScripts/LoadFilesintoStack/Menu=Load Files into Stack...</name>

<eventid>6F17BFA7-EFC

...
Translate
Adobe
Contributor ,
Oct 21, 2018 Oct 21, 2018

I managed to create a workaround for the issue.

Not perfect, but it works and I was only playing, I am sure you can tweak it further:

// (c) Copyright 2006.  Adobe Systems, Incorporated.  All rights reserved.

var currentDoc = app.activeDocument;

/*

@@@BUILDINFO@@@ Load Files into Stack.jsx 1.0.0.1

*/

//

// Load Files into Stack.jsx - does just that.

//

/*

// BEGIN__HARVEST_EXCEPTION_ZSTRING

<javascriptresource>

<name>$$$/JavaScripts/LoadFilesintoStack/Menu=Load Files into Stack...</name>

<eventid>6F17BFA7-EFC8-40EA-B850-7B95ED8EA713</eventid>

</javascriptresource>

// END__HARVEST_EXCEPTION_ZSTRING

*/

// debug level: 0-2 (0:disable, 1:break on error, 2:break at beginning)

//$.level = (Window.version.search("d") != -1) ? 1 : 0; // This chokes bridge

$.level = 0;

// debugger; // launch debugger on next line

// on localized builds we pull the $$$/Strings from a .dat file

$.localize = true;

// Put header files in a "Stack Scripts Only" folder.  The "...Only" tells

// PS not to place it in the menu.  For that reason, we do -not- localize that

// portion of the folder name.

var g_StackScriptFolderPath = app.path + "/"+ localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts") + "/"

+ localize("$$$/private/LoadStack/StackScriptOnly=Stack Scripts Only/");

$.evalFile(g_StackScriptFolderPath + "LatteUI.jsx");

$.evalFile(g_StackScriptFolderPath + "StackSupport.jsx");

$.evalFile(g_StackScriptFolderPath + "CreateImageStack.jsx");

/************************************************************/

// loadLayers routines

loadLayers = new ImageStackCreator( localize("$$$/AdobePlugin/Shared/LoadStack/Process/Name=Load Layers"),

  localize('$$$/AdobePlugin/Shared/LoadStack/Auto/untitled=Untitled' ) );

// LoadLayers is less restrictive than MergeToHDR

loadLayers.mustBeSameSize = false; // Images' height & width don't need to match

loadLayers.mustBeUnmodifiedRaw = false; // Exposure adjustements in Camera raw are allowed

loadLayers.mustNotBe32Bit = false; // 32 bit images

loadLayers.createSmartObject = false; // If true, option to create smart object is checked.

// Add hooks to read the value of the "Create Smart Object" checkbox

loadLayers.customDialogSetup = function( w )

{

w.findControl('_createSO').value = loadLayers.createSmartObject;

if (! app.featureEnabled( localize( "$$$/private/ExtendedImageStackCreation=ImageStack Creation" ) ))

w.findControl('_createSO').hide();

}

loadLayers.customDialogFunction = function( w )

{

loadLayers.createSmartObject = w.findControl('_createSO').value;

}

// Override the default to use "Auto" alignment.

loadLayers.alignStack = function( stackDoc )

{

selectAllLayers(stackDoc, 2);

alignLayersByContent( "Auto" );

}

loadLayers.stackLayers = function()

{

var result, i, stackDoc = null;

stackDoc = this.loadStackLayers();

if (! stackDoc)

return;

// Nuke the "destination" layer that got created (M2HDR holdover)

stackDoc.layers[this.pluginName].remove();

// Stack 'em up.

if (this.createSmartObject)

{

selectAllLayers( stackDoc );

executeAction( knewPlacedLayerStr, new ActionDescriptor(), DialogModes.NO );

}

}

// "Main" execution of Merge to HDR

loadLayers.doInteractiveLoad = function ()

{

this.getFilesFromBridgeOrDialog( localize("$$$/private/LoadStack/LoadLayersexv=LoadLayers.exv") );

if (this.stackElements)

this.stackLayers();

}

loadLayers.intoStack = function(filelist, alignFlag)

{

if (typeof(alignFlag) == 'boolean')

loadLayers.useAlignment = alignFlag;

if (filelist.length < 2)

{

alert(localize("$$$/AdobeScripts/Shared/LoadLayers/AtLeast2=At least two files must be selected to create a stack."), this.pluginName, true );

return;

}

var j;

this.stackElements = new Array();

for (j in filelist)

{

var f = filelist;

this.stackElements.push( new StackElement( (typeof(f) == 'string') ? File(f) : f ) );

}

if (this.stackElements.length > 1)

this.stackLayers();

}

if (typeof(loadLayersFromScript) == 'undefined')

loadLayers.doInteractiveLoad();

   

workAround();

function workAround () {

var topLyr = app.activeDocument.artLayers.add().name = "top"

var btmLyr = app.activeDocument.artLayers.add().name = "bottom"

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

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

app.activeDocument.activeLayer.move(activeDocument, ElementPlacement.PLACEATEND);

function selectAllLayers(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    ref1.putName(cTID('Lyr '), "top");

    desc1.putReference(cTID('null'), ref1);

    desc1.putEnumerated(sTID("selectionModifier"), sTID("selectionModifierType"), sTID("addToSelectionContinuous"));

    desc1.putBoolean(cTID('MkVs'), false);

    var list1 = new ActionList();

    list1.putInteger(59);

    list1.putInteger(43);

    list1.putInteger(44);

    list1.putInteger(58);

    desc1.putList(cTID('LyrI'), list1);

    executeAction(cTID('slct'), desc1, dialogMode);

  };

function moveToOtherDoc(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

      var cDoc = currentDoc.name.replace("Document ", "");

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));

    desc1.putReference(cTID('null'), ref1);

    var ref2 = new ActionReference();

    ref2.putName(cTID('Dcmn'), cDoc);

    desc1.putReference(cTID('T   '), ref2);

    desc1.putInteger(cTID('Vrsn'), 5);

    var list1 = new ActionList();

    list1.putInteger(10);

    list1.putInteger(11);

    list1.putInteger(12);

    list1.putInteger(13);

    desc1.putList(cTID('Idnt'), list1);

    executeAction(cTID('Dplc'), desc1, dialogMode);

  };

selectAllLayers(true, true);

moveToOtherDoc(true,false);

};

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
Engaged ,
Aug 30, 2021 Aug 30, 2021

I'm sorry, I never thanked you for this. This was helpful. Thanks!

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 ,
Aug 30, 2021 Aug 30, 2021
LATEST

Maybe because you marked it as correct answer 😉

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