When importing a model with code,how to remove this new nested group information?

When importing a model with code
Importing a model always automatically adds a new nested group information named after the model file name, how to remove this new nested group information?

require 'sketchup.rb'

def import_model(file_path)
  model = Sketchup.active_model
  status, imported_entities = model.import(file_path, true) # The parameter true means merge into the current model
  if status
    UI.messagebox("Model imported successfully!")
  else
    UI.messagebox("Failed to import the model.")
  end
end

import_model('C://Users//Administrator//Desktop//box.skp')

Even after importing it and blowing it up once, it didn’t work.

require 'sketchup.rb'

def import_model(file_path)
  model = Sketchup.active_model
  status, imported_entities = model.import(file_path, false)
  if status
    # If the import is successful, blow up the model immediately
    imported_group = model.entities.grep(Sketchup::Group).first
    imported_group.explode if imported_group
    UI.messagebox("Model imported and exploded.")
  else
    UI.messagebox("Failed to import the model.")
  end
end

import_model('C://Users//Administrator//Desktop//box.skp')

QQ图片20240529224827

Maybe just explode the component, and purge ?

In fact, I don’t even need to blow up and clean up these extra operations, just import the model and keep the original group information of the model.

Ah, ok. I misunderstood.