There is no built in Method to rename Materials... However I have written a new Method 'material-name=.rb' that does that. Search for it in this Forum.
Usage: material.name="new_name"
It's NOT a script, however if you let the Method load and then call it it will work...
e.g. assuming each Component is in a separate Model file...
model=Sketchup.active_model
model_name=model.title
model.materials.each{|mat|
mat_name=mat.display_name
mat.name=mat_name+"["+model_name+"]"
}
If you want to make materials specific to Definitions then you' have to do something like...
model=Sketchup.active_model
model.definitions.each{|defn|
name=defn.name
defn_mats=[]
defn.entities.each{|e|
defn_mats<<e.material if e.material.name and not e.material.include?(defn_mats)
defn_mats<<e.material if e.back_material.name and not e.material.include?(defn_mats)
}
defn_mats.each{|mat|
mat_name=m.name
mclone=mat.clone ### NOTE; mat.clone is non-existent BUT it's quite easy to make it from the mat.name= code which already temporarily clones the material during its rename process...
mclone.name=mat_name+"["name+"]"
}
}
### you might want to purge at the end to remove unused materials...
model.materials.purge_unused
Note that this code is untried and only a basic outline...