Exporting Material Textures From 3D Warehouse Models

materials
textures
vray
diffuse_maps

#1

Hello,

I’m not sure if this is a Sketchup question or a V-Ray 3.0 Question.

TL;DR (Is there something that automatically extracts material diffuse maps into a folder for all materials to save doing it manually)

I recently took charge of the IT within our company, I have overseen the upgrade from Vray for sketchup 2.0 to 3.0.

One of the big differences I have seen is the distributed has had a huge upgrade with the Swarm, however it doesn’t like it when the materials diffuse maps are linked to an incorrect location. I’m working on getting these guys working to best practices with their models but there’s something that is bugging me and I am wondering if there’s a quick way to do it.

The easiest way to explain this is by using a blank model with an imported 3D warehouse object.

I’m going to use the model: Tech 3 Mistral 610 Component by Cyrus Khan purely as an example.

If I try and render this model on its own with nothing else in the scene at 4k on medium quality with progressive rendering turned off (I like to see it doing something with the little squares). Connect it to 20 or so swarm controlled machines the render will start and connect to maybe 1 or two swarm nodes but will not load on others. The render will finish FAR before the majority of the swarm have kicked in. Example in the screenshot below.

Now through a lot of trial and error/troubleshooting, I have found that the reason behind this is because the Diffuse maps are linked to Cyrus’s D Drive. Now I can go through all of these using a combination of the Vray Asset editor and the Materials section of the default tray. I can select the materials one by one. And click “Edit Texture in external editor” button" it opens it in my Windows 10 photo app and I can save it to a materials folder in the root of the model

Once ive done this to all of the materials. the Swarm will kick in in seconds after it starts rendering on all nodes.

So…

now the background is out of the way. Is there a way to export all of the diffuse maps from materials to a folder?


#2

If from the SketchUp application’s “In Model” Materials collection, then it’s a SketchUp question.

If from the Vray application’s “In Model” Materials collection, then it’s a Vray question (and best asked on the Vray forum.)


Re SketchUp Extensions:

The SketchUp Ruby API’s Texture class has no methods to access diffuse maps nor bump maps etc. (This would need to be done with some 3rd party image library most likely. But it’s not entirely impossible.)


#3

Thanks for the quick response!

I think its the sketchups in model materials collection. I’m just using Vray to identify if the path to the expected file location as the default tray only displays what the file name should be not where its looking for it.

I have had a look at the information about ruby you sent, it looks interesting, looks like what I’m after. But I cant say I fully understand it (Not a programmer unfortunately)

I think this is what I need but could use some help getting my head around it.

#write(filename, colorize = false) ⇒ Object

Writes the texture to file with option to preserve the color adjustments made by the material.

Examples:
material = Sketchup.active_model.materials[0]
basename = File.basename(material.texture.filename)
filename = File.join(Sketchup.temp_dir, basename)
material.texture.write(filename)

Returns Boolean - true if the method succeeded

Parameters:
:black_medium_small_square: filename — String - The filename to write the texture to.

:black_medium_small_square: colorize (defaults to: false) — Boolean - Allows for the texture to be exported with the color adjustments.

Returns:
:black_medium_small_square: Boolean - true if the method succeeded

Version:
:black_medium_small_square: SketchUp 2016


#4

I will expand on the method I’m using currently to export the textures.

first I am identifying if the texture is linked correctly

In the next screen the file path has an ! next to it indicating it cant find the file, this is obviously because the texture was linked to a file in the creators temp files those files are not on my PC

I will then go to the default tray and click the “Edit Texture Image in External Editor” (Highlighted in the image below) from here I save the texture to the server in an appropriate place (e.g a materials folder in the models root) this then either automatically relinks the file or I just have to restart the model and it will be correctly linked.


#5

Okay, your original question specifically said diffuse maps, but this workflow above is simply saving an embedded texture image out to a local file on the local machine, (ie, a SKP file is a proprietary binary container format.)

Yes, SketchUp Ruby extensions can write out the texture files in a batch way using the TextWriter class.

Since you’d be using the Vray extension for SketchUp, (and that the TextWriter class has been part of the API since the beginning,) I’d suggest first checking the SketchUp Vray extension features to see if they’ve already implemented a batch local texture writer command.

It is likely that there is already a sample extension that does this, or a freebie plugin.
Here is a link to the Plugins forum index over at SketchUcation:
https://sketchucation.com/forums/viewtopic.php?f=323&t=28782
(Do a search on “texture” in you browser after the page loads.)

REF:


By the way, SketchUp can natively batch export all the “In Model” materials to a folder of SKM archive files (if that helps in any way.)

Within the Materials inspector panel, switch to the “In Model” collection, then use the Details menu, and choose the “Save collection as…” option. The normal OS folder picker dialog will appear, with the path set in the Preferences > Files > Materials picker control as the current directory. (You’d need to manually navigate to the model’s folder, create a new folder, select and click OK.)


#6

Just a note that you can skip the steps of going into the Edit panel and opening in editor, and just right-click any material in the “In Model” collection, and choose “Export Texture Image” from the context menu.


#7

Apologies.

Being an IT Techie not a designer I’m not sure of all of the technical words I just went by what V-Ray was calling it and added Map to the end (because of bump map etc.)

But this is some fantastic help! I really appreciate you taking the time to assist me.

Regards

Matt


#8

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.