Skip to main content
Participant
May 11, 2018
Question

duplicate channel and move it

  • May 11, 2018
  • 2 replies
  • 649 views

i want to duplicate the channel from file_A to file_B.

and need to move it or set the position.

i found "channel.duplicate(Doc)" and "channel.duplicate(Obj,location)"

i have tried "channel.duplicate(Doc)", but itll locate {0px,0px}.

now, i want to use "channel.duplicate(Obj,location)"

like set it to {200px,200px} from {0px,0px}

but i dont konw how to use it..

Regards,

This topic has been closed for replies.

2 replies

Legend
May 14, 2018

To move channel use:

var ch = activeDocument.activeChannels;

// type here your channel name

activeDocument.activeChannels = [ activeDocument.channels.getByName("Alpha 1") ];

var d = new ActionDescriptor();

var r = new ActionReference();

r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));

d.putReference(stringIDToTypeID("null"), r);

var d1 = new ActionDescriptor();

d1.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("pixelsUnit"), 200);

d1.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("pixelsUnit"), 200);

d.putObject(stringIDToTypeID("to"), stringIDToTypeID("offset"), d1);

executeAction(stringIDToTypeID("move"), d, DialogModes.NO);

activeDocument.activeChannels = ch;

c.pfaffenbichler
Community Expert
Community Expert
May 11, 2018

I suspect you may have to use a Selection an the method translate.

But what you are describing sounds strange to me – why do you use a Channel and not a Layer (with Layer Mask possibly)?

What are you actually trying to automate?

Participant
May 11, 2018

Thanks for your response.

I have done that in my programming, which is read by the printer.

However, it can't recognize layer mask.

So, I want to know if it is possible to make it in Channel.

c.pfaffenbichler
Community Expert
Community Expert
May 11, 2018

It seems I don’t understand what you are trying to say.

Anyway:

The DOM method translate can be applied to Selections, by setting the activeDocoument.activeChannels to an Array of just the targeted Channel and selecting all one could then translate the channel’s content.

But the more efficient way would probably be recording the actual moving-operation with ScriptingListener.plugin and using that AM code in a function.