Here is my solution 😎
selectionObjectTemp = Sketchup.active_model.selection.to_a if selectionObjectTemp.length == 0 selectionTemp = nil else selectionTemp = selectionObjectTemp end if @definitions[definitionAImporter] definition = @definitions[definitionAImporter] else composantPath = File.join(@libPath,"#{definitionAImporter}.skp") if File.exist?(composantPath) definition = @definitions.load composantPath else UI.messagebox "le chemin n'existe pas; #{composantPath}" end end if selectionTemp != nil selectionTemp.each{|entitie| if entitie.is_a? Sketchup;;ComponentInstance entitie.definition = definition end } endD