Move all items in group and sub groups to new layer

Thanks for all your replies, really appreciated. Seems a shame we need to delve into Ruby code as I have loved using Sketchup for years, think it’s great, just gets difficult with complex patterns where I have alternate versions of the same model.

I will try and work out how to implement the methods you’ve described above, thanks again!

On your final note, are you saying copied groups, with no components, also share data, such as layer properties? I thought they were unique and that was effectively the difference between layers and components…

YES

Not unless you explicitly make them unique, in which case SketchUp creates a unique definition for the copy. (Basically it copies the definition, and then makes an instance from the new definition.) One main difference is that SketchUp hides the group definitions from the user in the component browser. But we Rubyists can see all. Another is that groups cannot glue-to faces.

I can’t see how to make a group unique. Components are ok, they have a “make unique” command, however groups not.

Let’s see if this can help explain with pictures. Remember my objective is to use one base model, then create a number of variations, which I can see in different scenes. I want to start each variation with a base model. So I want to copy the base model 10 times, and then modify each copy. Then scene 1 shows variation 1, and hides 2-10, scene 2 shows only variation 2 etc.

My model contains NO components.

here you can see i have only layer 4 showing, and I can confirm that ALL the groups, sub groups, and parts of those groups are on layer 4.

I then copy the group called V4 which is my base:

I then rename it to V5, and tag the selected “outer” group to layer 5.

I now try to hide layer 4, so I should see only the new copied model. but, it’s empty. I can see the selection box, however not the contents.

So I turn back on layer 4, select all the sub groups (however one can’t select their sub groups) and set them to layer 5

And then turn layer 4 off again, I see “some” more of original model

I now select one of the sub groups, “Rooms” and then edit it and do select all (same as selecting all it’s direct group children) and change to layer 5

And now toggle layer 4 off again, and I see some more of my copied element…

So basically you have to go into every group, and select all it’s contents, and set to the new layer, and then do that for every group inside every group and so on…

Depending on the complexity of the model, this could take hours, per copy…

So this is why I really would want to see a “change layers of this and all child elements” option within Sketchup… I know I am not the only one to ask.

If there’s some other way to achieve my requirement, then great, however so far it seems installing ruby plugins and so on is the only answer?

Don’t change the active layer. 99.9% of modeling should be done with layer0 as the active layer.
Changing the active layer leads to insanity. Personally I don’t understand why it’s so easy to change the active layer. It should be tucked away for those few times it is needed.

[quote=“Box, post:12, topic:11655”]
Personally I don’t understand why it’s so easy to change the active layer. It should be tucked away for those few times it is needed.
[/quote] Perhaps a Layers Observer plugin which spots if the active layer is not Layer0 and asks “Do you really want to do this…?” :wink:
EDIT: Like this… TIG-LayerWatcher.rb (631 Bytes)
Currently downloads are broken !!!
Edit2: See this: SketchUp Plugins | PluginStore | SketchUcation

Ooo… got me. Thought that was on the context menu.

Ruby API: Group#make_unique() says:

Group.make_unique

The make_unique method is used to force a group to have a unique definition.

Copying a group using the copy tool in SketchUp will create copies of the group that share a common definition until an instance is edited manually or this method is used. If multiple copies are made, all copies share a definition until all copies are edited manually, or all copies have this method used on them. This method ensures that the group uses a unique definition entry in the drawing database.

So with a group instance selected, at the console:
Sketchup.active_model.selection[0].make_unique
… or you can add it to the context menu using a code snippet, see:
[Code] Add “Make Group Unique” to popup context menu

But this still has the issue that group definitions are hidden in the SketchUp GUI.
This is one of the reasons many people avoid groups, except for the most basic things. (Some people avoid them altogether, and use components exclusively.)

Anyway, when you edit one of your groups, you ARE making it unique. It is just hard to tell this with the GUI.

No you don’t. You’re not listening, so I’ll attach an example model for you to poke about in.

As I said before, the subgroups (or sub-components,) should never be put on conflicting layers to begin with. They go on common layers if they will be visible on more than one scenario.

Scenario.skp (610.0 KB)

Your creating your own purgatory.

Everything that remains the same, should be on a common layer (or layers,), and be outside the “copy and change scenario” function. It makes no sense to be copying everything if everything does not change.

@wcndave

Listen to Box.

Read:
Does SketchUp Support Layers? — SketchUp Help

I think it would be wise to delete all layers, assigning all back to the Default Layer 0 and then apply your newfound knowledge of how layers work.

Dave, you can change the active layer if you need to insert a series of components using a certain layer.

It is best to immediately change it back to “Layer0” when done.

“Layer0” should always be visible, because it is the “primitives” layer. All edges and faces are assigned to use “Layer0”.

Personally I would work it like this:

  • Make everything as you want to see it on layer 0,
  • then create a layer and call it "Version 1".
  • Select all those groups that you want to be common to version 2
  • and "Copy" them.
  • Select all those groups that you want ONLY to be in version 1
  • and use the "entity info" to assign them to the new "Version 1" layer.
  • Hide Version 1
  • Paste in place.
  • Make this look like you want version 2 to look like and repeat the process.

    I only tend to have two or three options - more than that and I make separate files for each (have multiple copies of SU open at the same time; can copy/paste between them)

  • I do not understand why common groups would need to be copied.
    They should be on a common layer, that is visible in all the “scenario” scenes.
    Each “scenario” layer should have only those things unique to that particular scenario, and it would be visible in only the corresponding scene.

    If any of the geometry is absent from any of the versions, then it needs to be copied onto a new layer; an object cannot be assigned to more than one layer at a time: If it is common to 9 out of 10 versions, then you need 9 copies of it.

    What you can do is make the geometry a component so that every copy made over multiple layers will change as you change one. (just need to be careful that changes don’t have undesired effects on the versions you can’t see)

    If geometry is common to all versions then it doesn’t need to be copied or moved from layer 0

    No you do not. It goes on a “semi-common” layer. This layer is set visible in 9 out of 10 scenes.

    Grouped geometry that is different and needs to be changed, need only be copied once for that scene that is different, onto a layer that is visible in only that scene.

    No need to multiply the work 9 times !

    Geometry groups or component instances can be on any layer, or layers, … common or unique, … subject to the author’s organizational needs.

    It is primitives (edges & faces) that should be on “Layer0”.

    1 Like

    Please learn to understand how layers work, how groups work and how components work. It’s complex but remarkably simple once you get it.

    1 Like

    Sorry, I’ve been out of the country for a while, so wasn’t keeping up with the replies.

    Thanks very much for all the input, I do appreciate it.

    However I still don’t think it really works for me, as I can’t have any common objects. If I am sitting with my wife, and we say “how about we move that wall and add a window in version 8”, I don’t want it to change in any of the other versions.

    I suppose in effect, what I would like is 10 different models, and the ability to move between them using scenes, rather than opening different files.

    I.e. I want to look from an angle, and then toggle through my different versions.

    All I want is one base design, then create a copy on each layer, and make changes on that layer, so the scenes will work.

    Seems still rather odd that I cannot take a group and move it to a new layer, including all it’s child elements…

    You can - as long as the actual lines and faces are on group 0 and the groups are on the specific layers.

    I can’t see how.

    let me take a real example.

    I have a house model with a roof. I am trying to insert 10 variations of a new floor, each in a scene.

    I now want to copy the roof from scene 1 to scene 10 “external view”

    The roof is on layer 1, and I make a copy, and change to layer10, which contains all the elements for scene 10 only.

    when I then hide layer 1, the new roof is gone, because all the groups within the group are still on layer1

    I have to go into each group, and it’s sub groups, and their sub groups and so on, and select all, change layer.

    I have to do this so many times, I have spent 90% of my time just changing the properties, due to lack of inheritance when changing…

    Does this help.

    3 Likes

    Sort of, however it’s not what seems to happen for me. There must be a logical reason, however I can’t see it.

    I will upload an example here, a simple one.

    I have a model with the following:

    Layer 0: items that appear everywhere
    Layer Start Only: layer for items that only appear on the “what it looks like now” scene
    Layer Option 1: my first design
    Layer Option 2: my second design
    Layer External 1: first design with the roof on

    I then have 4 scenes

    Scene Start: Layer0 + start only
    Scene 1: Layer0 + option 1
    Scene 2: Layer0 + option 2
    Scene 1-External: Layer0 + option 1 + Layer External 1

    In the model uploaded, everything works fine through the scenes, however I have not put the roof on Scene: External 1.

    I want to copy it from the starting model.

    So I do this:

    • Make “start only” layer visible
    • copy the roof
    • move the roof to layer “External 1” (which is a visible layer)
    • new roof disappears
    • need to go in and change the layer of all the sub groups…

    You can see it in action here:groups.skp (157.9 KB)

    Imagine this with tens of layers, tens of copies, and tens of nested layers of hundreds of groups…

    Again… @wcndave …heed what you read.

    In your example model I find all the raw geometry within the Group named ‘Option 1’ is assigned to a layer other than the default Layer 0

    If you persist in changing the active layer away from the Default Layer 0 you’re inviting modeling mayhem.

    You’re making the model way more complex than it needs to be.
    Changing the layer assignment of a Parent group does not change the layer assignments of its subgroups.
    Leave your subgroups on the default layer and assign only the topmost (parent) groups to other layers.

    2 Likes