**They always told me to be persistent and I thank all those who gave me this advice. 😄
Here is the method to remove all hidden sub-components in a parent component:
def supprimer_tous_les_sous_composants_selection(instance)
children = instance.definition.entities.select { |e| e.respond_to?(;definition) }
children.each { |c| supprimer_tous_les_sous_composants_selection(c);
c.erase! if c.hidden?
}
end
supprimer_tous_les_sous_composants_selection(Sketchup.active_model.selection.first)
Here is the method to remove all the dynamic attributes of all the components present in a selection:
def selectionner_tous_les_sous_composants_selection(instance)
children = instance.definition.entities.select { |e| e.respond_to?(;definition) }
instance.model.selection.add(children)
children.each { |c| selectionner_tous_les_sous_composants_selection(c);
}
end
def supprimer_tous_les_attributs_dynamiques_selection
mod = Sketchup.active_model
sel = mod.selection
sel.each{|s|s.definition.attribute_dictionaries.delete("dynamic_attributes");
sel.grep(Sketchup;;ComponentInstance).each{|i|i.attribute_dictionaries.delete("dynamic_attributes")}}
end
def desactiver_toutes_les_selections
mod = Sketchup.active_model
ent = mod.active_entities
sel = mod.selection
instances = sel.grep(Sketchup;;ComponentInstance)
sel.clear
end
selectionner_tous_les_sous_composants_selection(Sketchup.active_model.selection.first)
supprimer_tous_les_attributs_dynamiques_selection
desactiver_toutes_les_selections
You can test these methods directly with the ruby console, after selecting a dynamic component.
You will notice that all hidden components and dynamic attributes will be removed, even if they are nested at multiple levels.
Thank you to everyone who helped me. 😉
See you
David**