Help me set funtion outer shell for components

Please write help me set funtion outer shell with component “obj” use Ruby code


Untitled.skp (176.7 KB)
I am very grateful for your help

OuterShell is a boolean operation that requires two (2) objects …

obj = Sketchup.active_model.selection.first
obj.outer_shell(obj2)

Both groups must be manifold (watertight) solids, otherwise the operation will do nothing.

REF: https://ruby.sketchup.com/Sketchup/Group.html#outer_shell-instance_method

1 Like

If there is no other way, please help me write code to scan the groups and outer shell in turn,

You need to at least TRY. (I am not going to write your extension for you.)
Post failing code so we can help you see any errors.

AND … be more specific about what you need code to do.
If you cannot explain well in English, then use Google Translator to make English questions.

1 Like

I did it

def self.remove_subcomps(definition)
definition.entities.each{|e|
if e.is_a?(Sketchup::Group)
self.comp_to_group(e)
elsif e.is_a?(Sketchup::ComponentInstance)

self.remove_subcomps(e.definition)

		self.comp_to_group(e)            
	end#if
}

end#def

def self.comp_to_group(inst)
inst.explode
end #def

        model = Sketchup.active_model
        entities = model.active_entities 

gg = entities.find_all {|ent| ent.name == ‘Obj’ }

gg.each { |a|
self.remove_subcomps(a.definition)
}

Please edit the post above and correctly delimit the code block. See …