[Plugin] Global_Material_Change
-
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 ??
#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 !
-
Thanks, I know I'll have great use of it.
-
Here's v1.1...
Usage:
- Select entities.
[IF there's no selection ALL active entities are used] - Activate the script from the Plugins Menu.
- Choose Old Material [to be replaced].
[<< DEFAULT >>=NO Material, << ALL >>=ALL Materials &
then Alphabetical list] - 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....
- Select entities.
-
Thank you TIG - i'll give it a try - it's a plug in i've been thinking about for some time..
-
really useful!
-
So far, so good. I can see it being a big time saver.
Thanks, John
-
Very useful, thanks.
-
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?
-
Here it is on my screen.
-
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!
-
Thanks Tig
Huge time saver!!
-
My thanks too, Tig!
Very useful script. -
very useful..
-
Thanks.. It works like charm.
-
Just what I needed. Thanks!!
-
bravo!!
-
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!
Advertisement