Select all groups with the same material

I have been given this overly detailed model. Its an as-built that has nuts and bolts modelled in detail and its painful to use.

I need to drastically slim it down if I’m to work with it. everything is a unique component and a unique instance so I cant mass select and delete.

Things do seem to be some what colour coordinated. Is there an extension that can select all “objects” by material? All the elements are grouped so it would need to be able to make the selection deep inside grouping layers.

Thanks.

Are the faces painted or the group/components?

I think the component is painted.

I should mention it was modelled in NavisWork and imported into Sketchup

Are you intending to delete the nuts and bolts? You can right click on the component’s thumbnail in the Components panel and choose Delete. It will delete all instances of the component even if in nested components/groups.

1 Like

Selection toys has a “Select by material option” - maybe check that one.

1 Like

It appears every nut and bolt is unique deleting one component does not remove the others.

That stinks! Getting rid of all of them ought to improve your model’s performance by quite a lot.

yeah, that nasty!

I’d be inclined to ask for the original file in it’s original format. It’s clearly been converted from something and a load of data thrown away.

I have installed selection toys and im not seeing this function. even in the extended UI. Do you know of any in-depth tutorial or could you provide a screen shot?

Right click object that has the material on it you want to select and choose active with selected materials.

I suspect if there is a lot of nesting then it might not get everything (or anything)

Unfortunately it seems they are nested to deep for this method to work.

Are they all components, though? Maybe the easiest path is to remove each one via the Components panel. At least that doesn’t require burrowing into nests.

I feel like this is a job for a Ruby script. Can you separate and post a small portion of the model to mess around with?

I think this might take longer than just deleting bits as I see them as everything is broken up into awkward bits.

I mean these components could be anywhere and there isn’t a way from these images to know how vital they would be to the overall model.

I’d charge at least double to work on that file.

1 Like

As in post a section to the forum? I’m not sure if I could share much info I wouldn’t want to disclose confidential client information. I’m not sure how much meta data would be carried over.

Ha yer not an option for a salary man unfortunately.

Its a cursed chalice as its given me more info than I could ever get by myself but also its overwhelming.

1 Like

Give this a try into the ruby console - colordropper select the material you want to find groups of first.


model = Sketchup.active_model
material = model.materials.current

if material.nil?
  UI.messagebox('No active material selected.')
  return
end

results = []

walker = lambda do |entities|
  entities.each do |ent|
    if ent.is_a?(Sketchup::Group) || ent.is_a?(Sketchup::ComponentInstance)
      # Add the entity if its instance-level material matches
      results << ent if ent.material == material

      # Recurse into child entities
      child_entities =
        ent.is_a?(Sketchup::Group) ? ent.entities : ent.definition.entities

      walker.call(child_entities)
    end
  end
end

walker.call(model.entities)

model.selection.clear
results.each { |e| model.selection.add(e) }

puts "Selected #{results.size} group(s)/component instance(s) using material: #{material.display_name}"

1 Like

Fair play, and probably not necessary for folk more Ruby savvy than I…