Nesting a single group in a new component

Is there a quick trick to nesting an existing single Group into a New Component?

Fundamentally I am using Profile Builder and I need to preserve the Assembly (Group). I need the Component for my BIM workflow.

If I use Convert Group to Component the Grouping is lost. I need to keep the Group so I can come back later and add details / or other Groups to the Component. I can get around it by duplicating the group, making the component and then deleting the copy, but that doesn’t feel very efficient.

Why don’t you use the Profile Builder option to draw with componentes instead of groups?

1 Like

Thanks, I have just discovered a whole new area of PB options under the menus that I didn’t know existed. School day!

The “Create component” option doesn’t solve my nesting problem. I’m looking to have the Assembly nested in a new component.

I think I have a solution. If I plan ahead and use Edit > Create Component and then draw the Assembly then it is nested.

1 Like

This quick plugin, will give you a context menu: “Wrap Group into component” if you right click on a group. There shouldn’t be any other object selected otherwise you wont get the context menu.

A nesting component definition name will be as the original group name + “-nest”. (E.g. if the group name is “mygroup” the component definition will be “mygroup-nest”, it there is no name of group, it will be “-nest” ).
You can undo it.

As usual: No warranties use it your own risk! :wink:

Dezmo_Group_into_component.rbz (541 Bytes)

Code
module Dezmo
module WrapGroupToComponent
  extend self
  @@loaded = false unless defined?(@@loaded)
  
  def wrap_to_comp(group)
    model = Sketchup.active_model
    entities = model.active_entities
    model.start_operation("Wrap Group into component", true)
    wrap_group = entities.add_group(group)
    wrap_instance = wrap_group.to_component
    wrap_instance.definition.name = group.name+"-nest"
    model.commit_operation
  end
  
  def sel_group
    sel = Sketchup.active_model.selection
    if sel.single_object? && sel.first.is_a?(Sketchup::Group)
      return sel.first
    end
    nil
  end
  
  unless @@loaded
    UI.add_context_menu_handler{|context_menu|
      if sel_group
        context_menu.add_item("Wrap Group into component"){
          wrap_to_comp(sel_group)
        } 
      end
    }
    @@loaded = true
  end

end
end
1 Like

Many thanks!!!. Whilst I might have a workflow solution above, I know in reality I’m not that organised. This will be very handy.

1 Like

Without extensions or plug ins - create your new component, select the group, CMD X the group to delete it (temporarily), open the new component for editing, paste in place the group, close the component edit and you have a nested group inside the component.

2 Likes