Move all items in group and sub groups to new layer


#1

I am trying to make several different layouts for a house. I have some core groups of elements, and then I want to copy them and make different layouts. Then I use scenes to move between them to show other people.

The problem is that when I copy a group, if I then use hide / unhide, and save the scene, when I go back it’s not really worked.

I read about this online and discovered that layers are really the way to go.

However when you copy a group, and then want to move the copied group to a new layer, you have to drill down into every single element and with a complex shape, (like a house) that takes a long time.

Is there any quick way to move a group and all it’s sub items into a layer?

Thanks

Dave


#2

You shouldn’t need to do this. If the outer-most context, ie, the master group is on a layer, and you turn that layer off, all of it should be hidden.

But to answer your question, you’d do this with the Outliner. Hold down the CTRL key on PC to select more than one entity.


#3

Selecting more than one entity I understand, however if I have 40 nested groups or more, I don’t want to select them all.

I tried your idea of “master only” like this:

created 3 items and nested them, all in layerA, create sceneA
copy the master group to group2, changed top/master group to layerB
created sceneB

Go to sceneA and hide layer B, save sceneA
Go to sceneB, hide layer A, save sceneB

Then page up / down between scenes, the items from scene A are showing in scene B…

So I can’t get this to work as you say,

If I go in and double click each sub group, and then select all, and then allocate to layer B, then both scenes work.


#4

I didn’t say it should work the way you did it.

On sceneB is group1 (which is all on LayerA,) visible ? It should not be as LayerA is off.

Anyway… I did not mean to indicate that this would work correctly, if any of the groups have conflicting layer assignments.

They should not, obviously.

Only the outermost groups should be on the “visibility layers” or “scene layers” if you wish to describe them that way. A good example would be a visibility layer for each floor of a building, with a corresponding scene page.

All the sub-groups or components can be on other shared layers, “Windows”, “Doors”, “Furniture” etc.


#5

This is exactly what I think I have…

GroupA is attached to LayerA and has lots of sub groups
GroupB is attached to LayerB and has lots of sub groups, including items from layerA

SceneA has only layerA visible in settings, however also shows sub groups from GroupB, ie those items within groupB that are attached to layerA

I have done one Layer per floor, and then I want to do a bunch of variations on final floor, about 10 different scenes.
However items from other scenes show. Then I change the settings until what I see is correct. Then go to a different scene and back again, no other action. The scene I just saved is completely different than when I left it. Some items are not showing, and some from other layers are showing.

That’s why I gave up using hide / unhide, as those states are simply not saved in scenes. However layers get mixed up too.

Have therefore 2 very time consuming tasks before I can even start work.

  1. each time I add a layer, I have to go back through every one of 20 scenes and turn it off. Not sure why the default is not to have it not in scenes, as it was not there when I saved the scene and now it is. 20 scenes and 20 layers = about 400 uncheck and save operations… very very boring.

  2. When I copy my boilerplate to a new layer, I have to go through hundreds of nested groups and change the layers. 20 times. I have seen this as a feature request so many times, to do “include all sub elements”, however we keep getting told we are “doing it wrong”.

Also I can’t see what I did differently from what you suggested? You said that the master-group layer will control the visibility, however in scenes it doesn’t…


#6

The bold is a no-no. They cannot contain competing visibility layers. They do, and of course you have visibility issues.

They are saved if the appropriate property boxes are checked for the scene in the Scene Manager.

The Layer Manager needs work. The settings are settable via the Ruby Console:
http://www.sketchup.com/intl/en/developer/docs/ourdoc/layer#page_behavior
Unfortunately, it be best to set the layer page behavior before making all the pages.

A page keeps a list of layers that do not have their default behavior. If a layer is not in that list, then it is set to its default visibility determined by one of these values:
LAYER_VISIBLE_BY_DEFAULT: 0x0000
LAYER_HIDDEN_BY_DEFAULT: 0x0001

To set it’s default behavior to hidden:

Sketchup.active_model.active_layer.page_behavior=1

For new pages:
LAYER_USES_DEFAULT_VISIBILITY_ON_NEW_PAGES: 0x0000
LAYER_IS_VISIBLE_ON_NEW_PAGES: 0x0010
LAYER_IS_HIDDEN_ON_NEW_PAGES: 0x0020

The “out of the box” setting for new pages, is to use the default setting. Or you could be double sure:

Sketchup.active_model.active_layer.page_behavior=0x1|0x20 # which is 33 decimal

Ruby documentation URL redirects are not working at 100%
#7

module WcnDave
  def self.hide_active_layer_on_all_pages_but_active_page
    m = Sketchup.active_model
    ol = m.active_layer
    m.active_layer="Layer0"
    op = m.pages.selected_page
    m.pages.each{|p|
      next if p==op
      t = p.transition_time
      p.transition_time= 0
      m.pages.selected_page= p
      ol.visible= false
      p.update(127)
      p.transition_time= t
    }
    m.pages.selected_page= op
    m.active_layer= ol
  end
end

You can rename the method to something shorter.
call it via: WcnDave::method_name


#8

You realize that groups are just a special form of component ? This means that they also have a component definition. It is the definition that owns the entities collection.

If you haven’t made each copy unique, then all instances share the same definition.

So if you edit one of the instances, your editing them all. As you drill down into nested groups, changing layers, your actually changing the layer for all instances.

You need to right-click the copies and “Make Unique.”


#9

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…


#10

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.


#11

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?


#12

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.


#13

[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: http://sketchucation.com/pluginstore?pln=TIG_LayerWatcher


#14

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.


#15

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.


#16

@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.


#17

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”.


#18

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)


  • #19

    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.


    #20

    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