@tig said:
This alternative one-liner will process all selected component-instances, making those instances take the material of the first face found within the component's definition.
ms=[];mod=Sketchup.active_model;mod.selection.grep(Sketchup;;ComponentInstance).each{|i|d=i.definition;d.entities.grep(Sketchup;;Face).each{|f|ms<<f.material};m=ms.compact[0];i.material=m};
To make a menu item of such simple commands you can try the following.
It's not difficult - just take care...Use a plain-text editor, like Notepad++ [or TextWrangler on a MAC], and add a new file into your Plugins folder*** named say 'MyOneLiners.rb' - ensure that its encoding is set to UTF-8.
Add this line to the very start of the file to be on the safe side:
# encoding: UTF-8
Then add the following line for each 'one-liner'...
UI.menu("Plugins").add_item("TITLE"){CODE}
Substituting your desired 'name' for your command in place of TITLE [keeping the paired ""], and also copy and paste the full code into where it says CODE [leaving the pair of enclosing {} ]
Do a new line for each command you want.
Save the RB file, and restart SketchUp to see your new command[s] listed under the SketchUp Extensions menu [previously called Plugins]...
***To open your Plugins folder [which is hidden by default] just copy+paste+enter this one-liner into the Ruby Console:
UI.openURL("file;///#{Sketchup.find_support_file('Plugins')}")
You could even add that command to your menu items, as say "OpenMyPluginsFolder" !
Work fine thanks for the help !!