sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    [REQ] Materials Rename

    Scheduled Pinned Locked Moved Plugins
    2 Posts 2 Posters 1.2k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • bagateloB Offline
      bagatelo
      last edited by

      "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!!!

      While the cat's away, the mice will play

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        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...

        TIG

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement