[REQ] Materials Rename
-
"I'm organizing my library components from SketchUp, and because I use V-Ray to render my images, I put useful components names of the materials under the name of the component, to edit in V-Ray."
So, I wonder if it would be possible to create a script that renames the materials of these components according to some criteria. For example, suppose that I am editing a component called "table 045.skp" and it has the following materials: mapple wood, metal, white paint, etc.. After we run the script, the material would have the following names, such as:
wood mapple >> "wood table 045 01",
Metal >> "wood table 045 02",
white paint >> "table wood 045 03"The reason for this is that it's confusing to locate in the scene the names of the materials of the componentes for editing in Vray.
Here I'm giving some examples:
http://rapidshare.com/files/261432800/SHARE.rar
Please notice the axes location, the scale, the material names, the layer names, the group names.Thanks!!!
-
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...
Advertisement