[Plugin] Global_Material_Change

[Plugin] Global_Material_Change

Postby TIG » Thu May 22, 2008 4:55 pm

This script [Global_Material_Change.rb] works on everything in a selection [or if there is no selection it uses all active entities]...

You can choose any material that's loaded in the model to be replaced - you can also choose <Default>, or << ALL >> - 'ALL' will change all materials in the selection to the new one - that's useful if you want to remove all materials from something and go for say the <Default> material to replace it... You can likewise choose any 'new' material from those currently available. You are warned about processing 'ALL' materials and also 'ALL' active entities...

The end result is everything in the selection (or active_entities) that uses the chosen material is globally changed to the chosen new one. I works on entities, groups or component definitions - mining down into them to change any nested things too...

It's one step undoable...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Global_Material_Change

Postby mateo soletic » Thu May 22, 2008 5:24 pm

Tig
Thanks a lot, I just tried it , Great script. :thumb:
0

mateo soletic 
 

Re: [Plugin] Global_Material_Change

Postby Matt666 » Fri May 23, 2008 7:00 am

Hi Tig !
Excellent Plug-in !!
I have translated it in French language...

I tried to create similar script... It works differently, and I have some problems...
1- Select a face with the old texture
2- Choose the new texture in the 'paint' palette
3- Apply "Add to the model" in the right click context menu in the palette
4- Run the script.

The third stage is a problem. I can't add the texture directly with the code... And if you don't do that, the texture is not saved. Do you have any method ??

Code: Select all
#Replace texture definition of a face with the active texture in the palette

def process_textures(entities, anctxt, newtxt)
   entities.each do |entity|
      case entity.typename
      when 'Group'
         process_textures entity.entities, anctxt, newtxt
      when 'ComponentInstance'
         if entity.material == anctxt
               entity.material = newtxt
         end
         edef = entity.definition
         process_textures edef.entities, anctxt, newtxt
      when 'Face'
         if entity.material == anctxt
               entity.material = newtxt
         end
         if entity.back_material == anctxt
               entity.back_material = newtxt
         end
      end
   end
end

def reptxt
   model = Sketchup.active_model
   ss = model.selection
   model.start_operation "Remplacer textures"
   if model.materials.current !=nil
      active_material = model.materials.current.name
      puts "Texture active = " + active_material
      if ss.empty?
         UI.messagebox("Aucune selection.")
         return nil
      else
         ent = ss[0]
         if ent.typename == "Face"
            puts "\nL'entité sélectionnée est de type Face."
            if ent.material !=nil
               process_textures model.active_entities, ent.material, active_material
               model.commit_operation
            end
         else
            UI.messagebox("\nL'entité sélectionnée n'est pas de type Face (" + ss[0].typename + ").")
         end
      end
   else
      UI.messagebox("Aucune texture active.")
      return nil
   end
end

if not file_loaded?("reptxt.rb")
   UI.menu("Plugins").add_item("Replace texture definition"){reptxt}
end



Thank you !
0
Frenglish at its best !
My scripts

Matt666 
 

Re: [Plugin] Global_Material_Change

Postby Pixero » Fri May 23, 2008 7:41 am

Thanks, I know I'll have great use of it.
0
User avatar
Pixero 
Premium Member
Premium Member
 

Re: [Plugin] Global_Material_Change

Postby TIG » Fri May 23, 2008 2:30 pm

Here's v1.1...

Usage:
1. Select entities.
[IF there's no selection ALL active entities are used]
2. Activate the script from the Plugins Menu.
3. Choose Old Material [to be replaced].
[<< DEFAULT >>=NO Material, << ALL >>=ALL Materials &
then Alphabetical list]
4. Choose the desired New Material.
[<< DEFAULT >> = No Material]
To access Materials that are off the visible list type the first letter - e.g. 'W' and use up/down arrow-keys to move to the one you want e.g. 'W'hite...

History:
1.0 20080522 First issue.
1.1 20080523 Lists alphabetical & guidance on arrows.
Progress 'ticker' added...

.
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Global_Material_Change

Postby CadFather » Fri May 23, 2008 3:41 pm

Thank you TIG - i'll give it a try - it's a plug in i've been thinking about for some time.. :P
0
Quarr-IT - SketchUp Training from the Master.. http://quarr-it.com/
User avatar
CadFather 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Global_Material_Change

Postby Julius » Mon May 26, 2008 2:16 pm

really useful!
0

Julius 
 

Re: [Plugin] Global_Material_Change

Postby JClements » Mon May 26, 2008 3:00 pm

So far, so good. I can see it being a big time saver.

Thanks, John
0
John
Illustrator
Beaverton, Oregon
User avatar
JClements 
Premium Member
Premium Member
 

Re: [Plugin] Global_Material_Change

Postby boofredlay » Tue May 27, 2008 6:57 pm

Very useful, thanks.
0
User avatar
boofredlay 
Global Moderator
 

Re: [Plugin] Global_Material_Change

Postby plot-paris » Tue May 27, 2008 7:02 pm

may be I am stupid. but I cant find the ruby (I pasted it in the SketchUp Plugin folder. but it doesn't show up in the plugins window (neither does it in any context menu or the paint bucket window)...

is there something I dont know?
0
User avatar
plot-paris 
 

Re: [Plugin] Global_Material_Change

Postby boofredlay » Tue May 27, 2008 7:29 pm

Here it is on my screen.
0
User avatar
boofredlay 
Global Moderator
 

Re: [Plugin] Global_Material_Change

Postby plot-paris » Tue May 27, 2008 7:37 pm

thanks Boofredlay,

I deleted it, copied it in the pluginsfolder again and it worked... no idea what happend.

now it shows up in the plugins tool bar and is doing a great job! :ecstatic:
0
User avatar
plot-paris 
 

Re: [Plugin] Global_Material_Change

Postby perk » Tue May 27, 2008 7:55 pm

Thanks Tig

Huge time saver!!
0

perk 
 

Re: [Plugin] Global_Material_Change

Postby Dan » Wed May 28, 2008 6:25 pm

My thanks too, Tig!
Very useful script.
0

Dan 
 

Re: [Plugin] Global_Material_Change

Postby Morpeth » Sat May 31, 2008 12:10 pm

very useful.. :enlight:
0

Morpeth 
 

Re: [Plugin] Global_Material_Change

Postby sepo » Sun Jun 01, 2008 5:52 pm

Thanks.. It works like charm.
0

sepo 
 

Re: [Plugin] Global_Material_Change

Postby bassie » Mon Dec 22, 2008 11:56 am

Just what I needed. Thanks!!
0

bassie 
 

Re: [Plugin] Global_Material_Change

Postby xrok1 » Sat Feb 28, 2009 6:38 am

bravo!! :sketchstatic:
0
“There are three classes of people: those who see. Those who see when they are shown. Those who do not see.”

http://www.Twilightrender.com try it!

xrok1 
 

Re: [Plugin] Global_Material_Change

Postby fewltu » Fri Jan 04, 2013 3:56 pm

Thank you so much!!! This is a huge help to me for setting up renderings for export. One huge improvement I would suggest is the ability to select multiple "old" materials to be replaced with one "new" material all at once. Thanks again!
0

fewltu 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Plugins

Who is online

Users browsing this forum: Dave R, dtrarch, Gábor, kohya, linkph, mayasaint, mikehathaway, waci123pl and 14 guests

Visit our sponsors: