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

Move selected objects to layer

Contributor ,
Feb 28, 2019 Feb 28, 2019

Copy link to clipboard

Copied

Hi,

     I want to move selected objects into new layer. Unable to move the object if if is sub selection of group.  How to handle this case?

     My process is

     1. I need to select  all  objects the right side of the page using bounds.

     2. Move into new layer

     Issue : If i move selection objects as it is design is affecting due to order of the objects (ie., textframes & rectangles).  So i group it and moving into layer. Its throwing issue, when a object is inside the group could not able to group it.

     If i ungroup and proceed, properties (ie., effects) of the grouped object is getting lost. How to handle such case..

    

Thanks,

Sudha K

TOPICS
Scripting

Views

1.1K

Likes

Translate

Translate

Report

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 28, 2019 Feb 28, 2019

Copy link to clipboard

Copied

I am not sure if i understood your issue completely. What i understood is that you want to move a group containing a group into a new layer and then ungroup the outer layer. It should work fine and the ungroup should keep the elements on the new group provided the pasteRemembersLayers flag is set to false. This flag is version dependent and was added i suppose in C5.5 or CS6. The following code should work, wherein you start with the selection of all the elements that you want to group, move to a new layer and ungroup

app.clipboardPreferences.pasteRemembersLayers  = false

var gr = app.documents[0].groups.add(app.selection)

var lay = app.documents[0].layers.itemByName("Layer 3")// this is the layer that you want the items to move to

gr.move(lay)

gr.ungroup()

See the screenshot of my document contents.

Screen Shot 2019-02-28 at 5.13.10 pm.png

Likes

Translate

Translate

Report

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
Contributor ,
Feb 28, 2019 Feb 28, 2019

Copy link to clipboard

Copied

Hi,

  1. My selection of part of the group and other objects.  if i group those elements throwing error.

2.  If i ungroup and continue the above process, effects applied group is getting lost. How to

     Effects.png

Groups.png

Likes

Translate

Translate

Report

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 28, 2019 Feb 28, 2019

Copy link to clipboard

Copied

I still don't understand if the need is just to move a set of elements which can contain group of elements as well in addition to other elements like rectangle etc, then the outer group is something that you will create so this group should not have any effects applied to it and hence the ungroup should not cause any issues.

Now if you want to ungroup and then still preserve all the effects on the constituent elements, then i suppose you will have to copy the effects from groups TransparencySetting to the group elements TransparencySetting. Something like

var grp = app.selection[0]

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

{

     if(grp.transparencySettings.bevelAndEmbossSettings.applied)

     {

          //You might wanna check if this setting is already applied on the pageitem then should you copy or not

          grp.pageItems.transparencySettings.bevelAndEmbossSettings.applied = true

          //Copy now all the properties of the bevelAndEmbossSettings from grp to the pageitem

     }

}

//Now you can ungroup

-Manan

P.S. :- I have not tested this so there may be some errors.

Likes

Translate

Translate

Report

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 28, 2019 Feb 28, 2019

Copy link to clipboard

Copied

Hi Sudha,

if an object should be moved to a different layer that is part of a nested structure like a group:

1. Duplicate the object

2. Move the dulicate

3. Remove the original

Regards,
Uwe

Likes

Translate

Translate

Report

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 28, 2019 Feb 28, 2019

Copy link to clipboard

Copied

In case the group has an effect applied:

1. Duplicate the group

2. Remove all not necessary objects from the duplicated group.

3. Move the duplicated group to the layer.

Do not ungroup the duplicated group!

4. Remove the object from the original group.

Regards,
Uwe

Likes

Translate

Translate

Report

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 28, 2019 Feb 28, 2019

Copy link to clipboard

Copied

Also note: A group is able to contain only one element.

Likes

Translate

Translate

Report

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
Contributor ,
Feb 28, 2019 Feb 28, 2019

Copy link to clipboard

Copied

Hi Laubender/Manan,

     Thank you for your replies...

     My Requirement is,

     1. Selecting all objects from cover file right side using bounds. So object may be group or textframe or rectangles. Selecting using pageitems loop.

     2. Elements inside the groups are selecting instead of group when i use page items.If i move selection to the new layer getting the above layer.

     3. Getting issue in moving object due to elements order so group the selection and moving.

     4. Unable to group because selection is part of group so throwing error. For this if i ungroup the group elements effects applied to the group is getting lost.

Likes

Translate

Translate

Report

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 ,
Jun 14, 2022 Jun 14, 2022

Copy link to clipboard

Copied

I search a solution and I do that :

Note : if you have 2 pages facing pages, it do it on the 2 pages. 
First, I lock the layers i don't want to treat.

After, I select all objects

try{ app.menuActions.itemByID(276).invoke(); } catch(e) { exit(); } // select all

After I activate the layer I want :
app.activeDocument.activeLayer = app.activeDocument.layers.itemByName("MyLayer");

I group all of the elements in my selection : 
try{ app.menuActions.itemByID(118844).invoke(); } catch(e) {} // group

I attrib to my selection the layer i want :
app.activeDocument.selection[0].itemLayer = app.activeDocument.layers.itemByName('MyLayer');

I ungroup :
try{ app.menuActions.itemByID(118845).invoke(); } catch(e) { } // ungroup

 

Likes

Translate

Translate

Report

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 ,
Jun 14, 2022 Jun 14, 2022

Copy link to clipboard

Copied

Sorry i don't works because when you ungroup, all objects are goinig back to their original layer.  

Likes

Translate

Translate

Report

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 ,
Jun 14, 2022 Jun 14, 2022

Copy link to clipboard

Copied

"when you ungroup, all objects are goinig back to their original layer"

 

Not necessarily.

Depends on an option with the Layers panel.

By scripting it is:

app.generalPreferences.ungroupRemembersLayers = true; // or false

 

Regards,
Uwe Laubender
( Adobe Community Professional )

Likes

Translate

Translate

Report

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 ,
Jun 14, 2022 Jun 14, 2022

Copy link to clipboard

Copied

LATEST

So it's works. Thank you very much.

Likes

Translate

Translate

Report

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