[Plugin] Very fast texture writer

[Plugin] Very fast texture writer

Postby Didier Bur » Wed Feb 13, 2008 1:05 pm

Hi,
Instead of interating through all the entities of the model, dig in groups/components, etc, etc, this one iterates through materials and assign each material which has a texture to a virtual face, then deletes the face.
Much much faster, especially on huge models...
And as a side note, the write_all method seems to work, although Al Hart, author of "rps_texturewrite.rb" said that it did'nt.
Regards,
2
Didier Bur
Ecole Nationale Supérieure d'Architecture de Nancy (F)
http://rld.crai.archi.fr/rubylibrarydepot/
User avatar
Didier Bur 
 

Re: [Plugin] Very fast texture writer

Postby takesh h » Thu Apr 16, 2009 4:43 pm

This is a great plugin, Didier.
It's too precious to limit its users to "Developers only"... I added few lines to the Ruby so that everybody can implement it from [Plugin] menu. Find a line says [Export All Textures].

Call for help;
The Ruby is successful in extracting 70% of textures, I don't know what happens to other 30%. I tried it on some models from 3DWarehouse, and it seems to always leave some textures unexported. Exploding all groups and components didn't make any differences. Could any Ruby-experts take a look at it?
0
User avatar
takesh h 
 

Re: [Plugin] Very fast texture writer

Postby pilou » Thu Apr 16, 2009 5:14 pm

A little image of what this plug make?
0
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
pilou 
Top SketchUcator
 

Re: [Plugin] Very fast texture writer

Postby TIG » Thu Apr 16, 2009 5:45 pm

Pilou wrote:A little image of what this plug make?

Install it.
In the Ruby Console type fast_tw + <enter>.
It exports all of the model's materials (including any unused ones) as individual image files (jpg etc) into the model's folder.
...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Very fast texture writer

Postby pilou » Thu Apr 16, 2009 10:38 pm

thx Takesh San ;)

@Tig : there is a little error in your command! :o But I don't know what :oops:

error.jpg


rocks.jpg
0
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
pilou 
Top SketchUcator
 

Re: [Plugin] Very fast texture writer

Postby TIG » Thu Apr 16, 2009 11:48 pm

Pilou
You take me much too literally !
Type fast_tw
Then press the <enter>key.
I used the "+" as = "&" - meaning "and then you do..."... ;)
Vous me prendre trop à la lettre!
Taper à la machine fast_tw.
Ensuite, appuyez sur la touche-entrée.
J'ai utilisé la "+" = "&" - sens "et vous faire..."...

.
1
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Very fast texture writer

Postby pilou » Fri Apr 17, 2009 2:18 am

:oops:
I have presumed that
:mrgreen:
The Duhduh of the day :D
0
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
pilou 
Top SketchUcator
 

Re: [Plugin] Very fast texture writer

Postby free agent » Wed May 13, 2009 10:38 am

thank you for this very useful, and to takesh h for making it available through plugins dropdown - i hate the ruby consol :)
0
User avatar
free agent 
 

Very fast texture writer v0.41

Postby bentleykfrog » Sat Jan 08, 2011 11:58 am

Nice plugin Didier and takesh,

I've modified it slightly to allow for batch processing and updating of textures.

Update - January 15th 2011
This is a minor update to change the entity used to create a texture to a group. This limits any interference with the models geometry on export & import (thanks to AlexMozg for the code).

A description of all the operations are below. The plugin can be accessed by the menu [Plugins] - [Export All Textures]:

  • [Export All Textures]
    • This operation will export all the textures from the model to a 'textures' folder in the same directory as the model
  • [Export Settings] - [Update Model's Texture Paths]
    • When exporting textures with this option enabled, each texture path in the model will be updated to the path of the exported texture image.
  • [Import All Textures]
    • Choose a file within a folder to import all the textures in that folder. Each file is compared with the models textures by its namespace (ie. the file "AsphaltCloseups00212M.jpg" will be replaced with the file "AsphaltCloseups00212M" regardless of its extension)
  • [Import Settings] - [Only Update Existing Materials]
    • With this option enabled, only files with namespace equivalents to the models textured materials will be imported.
  • [Import Settings] - [Create New Materials for Unique Textures]
    • With this option enabled, files that have no namespace equivalents to the models textured materials will be imported into a new material.
  • [Import Settings] - [Create New Materials for All Textures]
    • With this option enabled, each texture file will be imported into a new material.
  • [Import Settings] - [Consolidate to Texture Folder]
    • With this option enabled, each texture file will be copied to the 'texture' folder.
  • [Export From Selection]
    • Only textures in the active selection will be exported to the 'texture' folder
  • [Import To Selection]
    • Only textures that have a match to the active selection's materials will be imported.
  • [Selection Settings] - [Make Painted Components Unique]
    • With this option selected, painted components in the selection that aren't unique to the selection will be made unique.
  • [Selection Settings] - [Materials Unique to Selection]
    • With this option selected, materials that aren't unique to the selection will be made unique. (ie. a duplicate of the material is made and all entities in the selection are linked to this duplicate)
  • [Selection Settings] - [Consolidate to Texture Folder on Import]
    • With this option selected, all imported textures will be copied to the 'texture' folder.

I haven't been able to replicate your exporting issues takesh, could you link me to an example?

Also, I haven't tested this on a mac, so there could be further issues.

Changelog
  • 15th January 2011 (v0.41)
    • Face->Group Change: Changed the entity used to create a texture file to a group (thanks to AlexMozg)
  • 14th January 2011 (v0.4)
    • Export/Import Selection added: Export/import selection option added so parts of the model can be edited
    • Better Image Checking: The regex checking for BMP and JPEG images has been updated
    • Opacity & Color retained: Material opacity and color settings are now retained when they are modified
  • 9th January 2011
    • New Materials on Import added: On import, new materials are created for textures that have no existing matching materials in the model
    • Image checking: added some rudimentary regex image checking to the import script, could still be a bit buggy
    • Debug and reports: known errors are reported in the ruby console when open on operation

Known Issues
  • Targa files will import but can't be written with the TextureWriter
[/list]

-niall

PS:If you run into any trouble importing jpg,png,bmp or tif files please post the image to this topic so I can get a look at its header data.
0
Last edited by bentleykfrog on Sat Jan 15, 2011 6:01 am, edited 3 times in total.

bentleykfrog 
 

Re: [Plugin] Very fast texture writer

Postby jason_maranto » Sat Jan 08, 2011 8:54 pm

The import function doesn't work on Sketchup 8 Pro unless I'm missing something -- the textures folder is created but nothing is in it...

Best,
Jason.
0
I create video tutorial series about several 2D & 3D graphics programs.
User avatar
jason_maranto 
 

Re: [Plugin] Very fast texture writer

Postby TIG » Sat Jan 08, 2011 10:37 pm

jason_maranto wrote:The import function doesn't work on Sketchup 8 Pro unless I'm missing something -- the textures folder is created but nothing is in it...

Best,
Jason.

Do you mean, "The import function doesn't work..."
???
Try with the Ruby Console open and report error messages, if any...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Very fast texture writer

Postby jason_maranto » Sun Jan 09, 2011 1:22 am

Edit -- I got it working... It was user error on my part.

Great time-saver of a plugin!

Best,
Jason.
0
I create video tutorial series about several 2D & 3D graphics programs.
User avatar
jason_maranto 
 

Re: [Plugin] Very fast texture writer

Postby bentleykfrog » Fri Jan 14, 2011 10:28 am

I've updated the plugin to preserve opacity and color settings for each material. There's also improved regex in the image type checking function, which will better check for imported image filetypes. I've also included the option to export and import by selection, which will give you the option of mass editing textures from certain parts of your model. Follow the link: Very Fast Texture Writer v0.4
0

bentleykfrog 
 

Re: [Plugin] Very fast texture writer

Postby jason_maranto » Fri Jan 14, 2011 3:43 pm

Outstanding! :berserk: -- this makes creating and updating material libraries so much easier.

Best,
Jason.
0
I create video tutorial series about several 2D & 3D graphics programs.
User avatar
jason_maranto 
 

Re: [Plugin] Very fast texture writer

Postby AlexMozg » Sat Jan 15, 2011 2:05 am

bentleykfrog and all!
This code is even faster than the code with used temp face if the Outliner window is open.
It is better to create an empty group, rather than create face and then remove its edges:
Code: Select all
def quickly_tw(operation=true)
  model = Sketchup.active_model
  tw = Sketchup.create_texture_writer
# Iterate through materials, assign to face, load in tw
  model.start_operation "texture:)" if operation
  gr = model.entities.add_group
  model.materials.each do |mat|
    if mat.texture
      gr.material = mat
      tw.load(gr)
    end
  end
# Output textures
  tw.write_all(File.dirname(Sketchup.active_model.path) + "/", false)
  model.abort_operation if operation
end

And also and if by chance the temp face with the same coordinates is already defined in the model? Can this happen? ;)
Thank you bentleykfrog ;)
0

AlexMozg 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Very fast texture writer

Postby bentleykfrog » Sat Jan 15, 2011 6:02 am

AlexMozg wrote:It is better to create an empty group, rather than create face and then remove its edges


Nice idea AlexMozg, thanks for the code. I've updated the script to do this. I've also noticed the more times the operations are run, the slower the response from tw.write. I'm not exactly sure whats going on here but it seems if you re-open your file the lag goes away. Anyway, follow the link Very Fast Texture Writer v0.41
0

bentleykfrog 
 

Re: [Plugin] Very fast texture writer

Postby bentleykfrog » Sat Jan 15, 2011 6:38 am

jason_maranto wrote:Outstanding! :berserk: -- this makes creating and updating material libraries so much easier.

Best,
Jason.


Thanks Jason :)

I'm thinking of adding some proportion options on import to the next update. For example, you export some textures that aren't tiling well, batch process them through some texture tiling application, and then import the new textures and modify the proportions of the materials to suit...Maybe some options like:

[If Different, Fit Proportions] - fits the new texture inside the width and height of the material dimensions
[If Different, Preseve Proportions] - stretches the new texture to fit the material dimensions
[If Different, Respect Width] - Matches the width dimension and scales the height dimension to suit the new texture
[If Different, Respect Height] - Matches the height dimension and scales the width dimension to suit the new texture

What do you think?

-niall
0

bentleykfrog 
 

Re: [Plugin] Very fast texture writer

Postby jason_maranto » Sat Jan 15, 2011 5:17 pm

Sounds very good to me -- also if somehow a custom value for newly created materials could be input in a manner similar to below:

In the recent past I've made a large color range of tiles -- 183 RBG colors + 1 texture file set to colorize for each of the RGB values, all set to the same tiling with each RGB color becoming the custom name of the file.

So being able to automate a batch of new files by specifying:

1) Base Material name (ie: mytile_)
2) Comma separated or tab delimited (or similar) text file with RGB values and names (to be added at the end of the base name ie: mytile_bright green)
3) A Texture
4) Material options (ie: colorize, scale, transparency)

Would be a huge time-saver in instances like this -- I've done well over 2000 materials manually like this... to have that process automated would allow me to be far more productive. Although since I seem to be one of the few here excited by this maybe I'm alone in producing huge custom libraries...

Regardless, the plugin as it stands is fantastic and has already saved me a few hours of needlessly navigating for textures when creating materials... so thank-you again. :D

Best,
Jason.
0
I create video tutorial series about several 2D & 3D graphics programs.
User avatar
jason_maranto 
 

Re: [Plugin] Very fast texture writer

Postby hellnbak » Sun May 22, 2011 4:29 pm

I can't tell which is the latest version of this, very confusing.
0
"Politicians are just like diapers -- they need to be changed often, and for the same reason"
User avatar
hellnbak 
Premium Member
Premium Member
 

Re: [Plugin] Very fast texture writer

Postby Didier Bur » Sun May 22, 2011 7:34 pm

0
Didier Bur
Ecole Nationale Supérieure d'Architecture de Nancy (F)
http://rld.crai.archi.fr/rubylibrarydepot/
User avatar
Didier Bur 
 

Re: [Plugin] Very fast texture writer

Postby jason_maranto » Thu Apr 19, 2012 3:15 pm

I'm having a few issues with this plugin when importing image libraries:

1) The tiling settings for the images are coming in with the x and y scales reversed (the aspect ratio is reversed from the actual image).

2) I would like to retain any "-" and "_" characters in the image name (when converted to the SKM name).

Best,
Jason.
0
I create video tutorial series about several 2D & 3D graphics programs.
User avatar
jason_maranto 
 

Re: [Plugin] Very fast texture writer

Postby TIG » Thu Apr 19, 2012 3:48 pm

Around lines #90 and #129 it reads
mat.texture.size = [twidth,theight]
to swap the height/width values change it to read
mat.texture.size = [theight, twidth]
BUT the width SHOULD come first in the .size=[] method as it is originally coded... so I am perplexed... :?

Around line #59 it reads
filename = filename.delete('^A-Za-z0-9')
to keep the - and _ in file-names, change it to read...
filename.gsub!(/[^A-Za-z0-9_-]/, '')
This WILL work...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Very fast texture writer

Postby jason_maranto » Thu Apr 19, 2012 3:58 pm

Thanks TIG, I did my own hacks to the Ruby to make it usable for right now, but your code is much nicer so I will change it out :D

For the record the changes I made were at lines 344 and 368 -- but I only barely know my way around a Ruby file :knockout:

Best,
Jason.
0
I create video tutorial series about several 2D & 3D graphics programs.
User avatar
jason_maranto 
 

Re: [Plugin] Very fast texture writer

Postby andybot » Fri Feb 22, 2013 6:09 am

This is a fantastic help. Thank you!
0
my blog featuring recent projects
User avatar
andybot 
Premium Member
Premium Member
 

Re: [Plugin] Very fast texture writer

Postby unclebim » Mon Oct 20, 2014 7:25 pm

Is there any chance of running the plugin in SU 2014?
0
User avatar
unclebim 
 

Re: [Plugin] Very fast texture writer

Postby TIG » Tue Oct 21, 2014 1:02 pm

The original fast_tw.rb works in v2014, but is Ruby Console run.
This attached version is the same as the one in the PluginStore's RBZ.
fast_tw.rb

The Depot's fast_tw_3.rb is menu driven and has several extra options.
It is compatible with v2014.
This has some issues, which my post a little earlier explained how to fix.
This attached version has those issues fixed.
I have incremented it to fast_tw_3a.rb
fast_tw_3a.rb

In an earlier post in this thread another version of the RB was attached [confusingly with the same version suffix].
This is also menu driven and includes several additional options.
BUT this one is full of coding issues and it is NOT compatible with v2014.
This attached version has those issues fixed and is now v2014 compatible.
I have renamed it fast_tw_4.rb for the avoidance of doubt.
fast_tw_4.rb

Because of the non-standard RB naming conventions you should ensure any older "fast_tw" RB files are removed...
I have swapped the texture's height,width in the ..size=[], which [oddly] seems to work - if you have issues with that try editing the v3a/v4 RBs and find every ..size=[] and swap them back to be [width,height] ??
2
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Very fast texture writer

Postby unclebim » Wed Oct 22, 2014 8:00 pm

Thank you very much, TIG!
0
User avatar
unclebim 
 

Re: [Plugin] Very fast texture writer

Postby AcesHigh » Fri Nov 14, 2014 10:40 pm

Can I make an improvement request? It would be nice if you could choose if you want the texture exported with the MATERIAL name (as it happens now) or the original texture name, if available.
2

AcesHigh 
 

Re: [Plugin] Very fast texture writer

Postby samyell77 » Wed Mar 04, 2015 6:14 pm

Hi,
Great plugin - thanks! Always amazed by the fantastic plugins that you can find on sketchucation! Thank you...!
I like AcesHigh's point about material names - would be a handy feature but even without this plugin will come in very handy.
Sam
0
SU Pro 2016
Dell Precision M4800
PC Windows 10
Intel Core i7-4900MQ @ 2.80ghz
Nvidia Quadro K2100M
16gb RAM

samyell77 
 

Re: [Plugin] Very fast texture writer

Postby Lemoyne Architect » Wed Nov 25, 2015 9:16 pm

AcesHigh wrote:Can I make an improvement request? It would be nice if you could choose if you want the texture exported with the MATERIAL name (as it happens now) or the original texture name, if available.


I’m trying to use fast_tw on OSX 10.9.5 and SU 2015 and I’m getting file names such as "fa3c172f4fc034eb6af0489c89b26612.jpg” for everything. From the comment above, am I understanding correctly that it SHOULD save the files with the MATERIAL name you’d see in SU?

I’ve tried using both fast_tw_3a.rb and fast_tw_4.rb with the same results.
0
User avatar
Lemoyne Architect 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 

Next


 

Return to Plugins

Who is online

Users browsing this forum: No registered users and 19 guests

Visit our sponsors: