changing all my rhino model textures from png to jpg?

Hello all

i've got a model (with a lot of textures.)

all textures are png (.png's) and are working fine- visible in rhino etc.

however for other reasons (the next application i'm exporting too) i need all the textures to be jpg (.jpeg's).

I can convert the actual texture files without a problem into jpgs however- 
how do i change the link from within rhino? that is how do you tell rhino to search for the same texture fine name only with different extension?

just to clarify, i cannot afford to do this one by one- as i've got thousnads of these.

thanks very much


Tags: batch, jpg, material, model, png, rhino, texture

Views: 678

Replies to This Discussion

sorry for my english, and also i don't have a direct solution here... hehe... btw:

1) Why you need to use jpg instead of png? (it could be useful to know....)

2) If u have not any render plugin active, you can go in the material editor and find all "materials" sorted; it's a bit better than finding surface by surfce...

3) You can "lie" to the system: rename all you new texture.jpg to texture.png (be careful with overwrite the original real ones png, its better if u backup them somewhere else) then restart rhino to reload textures;

rhino will load textures with .png extensions but in fact they would be all .jpg coded.

(to see the extension go in control panel > folder options , but you probabily know... )

i hope it helps XD

This should in principle be scriptable, but I'm not getting it to work right now.  I will get back to you as soon as I figure something out...


Hello Riccardo & Helvetosaur, and thanks very much for the quick response :) i appreciate it.

1. i'm exporting the model to a VR (quite old) software called vega prime - and for some reason it creates errors with png and jpgs are fine.

(this is even though the textures are linked and working inside rhino as said before.)

2. i'm not sure i understand how this will help me - i can choose all instances of materials just with the selmaterialname but this will still result in 100's of these. (i've got well over 256 mats..)

3. this is the workaround i though would work- maybe i'm not doing this right? did you get it to work? 

sorry if i'm not following:

i'm viewing extensions in windows and the files are either jpg type or png type when i change the extension.

a) i've tried - rename "texture.png" >> "texture.jpg"  and restarting rhino and it still looked for the png.

b) if i understood you correctly you mean - rename "texture.png" >> "texture.png.jpg" ?

c) i'm also trying to get a workaround maybe through 3dsmax - actually thought this would be successful - i imported the file into max, then exported to obj but making max convert the .png textures to .jpg textures in the options. the textures actually were created as i wanted - and the .mat file also was good - referring to the .jpg textures - however , when importing the obj into rhino the geometry was still looking for the .png ! :(

i hope i was clear?

my idea of changing the file extension could have benn good while working inside rhino, but will almost sure be a mess while exporting out to another program...

probably the best slution for you should be what Helvetosaur said: a script.

(i'll try to re-explain better my "old" idea, try doing it with a small file/export:

your original texture: texture.png

your new texture in the same path-folder: texture.jpg

move away the original one, throw it in a backup folder...

rename the JPG one to texture.png not texture.jpg.png or texture.png.jpg (be sure to see ALL parts of filename, included file extensions)

you actually have done the opposite

in your rhino file you don't have to do any edit, just reload it...

when a surface will search for his old original "texture.png", he will find it!! but it would just be an jpg texture disguised as png... it works! i've alrady tested that...

but for your case, where you need to export out of rhino, it will probably a mess, and wont work.... just.. do a fast try.... )

1. Helvetosaur  - any news on the script ? to change the link from png to jpg?

2. Riccardo Majewski - just to clarify- this of course will work, but that's because when i "rename" the jpegs files - they are transformed to png, no? 

both the extension and in the details of the files it says they've become png and so they are exactly like the old textures rhino was looking for and that's why it's successful, no? 

the problem for me is that the textures being used by rhino will still be png and that will cause the errors down the line with the export.

3. by the way- i guess the thing that's not clear to me is what use is the OBJ and MAT files? if they don't do they job so to speak?

i mean the mat file specifically says to use the jpg files that are located in the same folder and then when i import the obj - it still is looking for pngs?

any thoughts on this?

i hope i was clear and thanks for your help so far :)

renaming a .jpg to .png in fact does not transform the file...

that one is only the extension part of the name of the file...

but here we are going OT

good news!

sill Helvetosaur's idea...

search for "material" in rhinoscript help

you can see the commands:

Rhino.MaterialId (intMaterialIndex)

Rhino.MaterialTexture (intMaterialIndex [, strFileName])

it could be easy to make a script with a For-Next cycle throught material index;

changing ALL materials refenrence


if you have some basics in rhinoscript it shouldn't be hard... i suppose...

i dont have much time now/today...

but for sure i'll try to make your script! i just hope it will work...

ok done ... XD

this script work for 5 materials, just kncrease the number "4" to how many materials you have less 1

this script work only if you have zero "." in the folders names of path location and only 1 "." in your textures filename...

copy/paste this inside a button:

-runscript (
sub cambiatexture

' for/next cycle for 5 times, if needed more, change the value "4" with what you need....
' if the number of cycle will be more than the number of materials in the file, the script will do an error
' but it will still do the work...
for i=0 to 4

' get the string with folder path + filename (extension included)
Dim material_texture : material_texture = Rhino.MaterialTexture (i)

' split the string where the point is "."
' we get an array where the first member (o) is the left part of the array (so path+ name) _
' and the right part (1) is the extension (probably "png" in your case)
' ATTENTION if in the folder's names of the patch or in the file there are more "." this script need to be modified
' (optional: we could insert an IF function to check if the second member IS "png"_
' so you can find out which of your original texture files is not an png file... )
Dim name_less_ext : name_less_ext = Rhino.Strtok (material_texture, ".")

' we add to the string another string: ".jpg"
Dim name_plus_ext : name_plus_ext = name_less_ext(0)&cstr(".jpg")

' reassign the edited texture reference to the material of this next/for cycle ( i )
Rhino.MaterialTexture i, name_plus_ext


end sub

i tried to add comment lines to help who want to learn scripting (and sorry for bad english)

in my pc it works.... let us know

thanks again Helvetosaur for make us remember the scripts XD

(my first idea was just a mess... )

wow thanks so much  Riccardo Majewski :)

i'll try this as soon as i get back home in a few hours 

and i'll let you guys know asap

thanks a million


P.S. do a backup or similar before start the script.... just in case

and after the script done his job... check everything the best you can,

because the script, in fact, EDIT your rhino file....

so do all your precautions... please

Unfortunately, I tried something similar, but it didn't work here...  Still trying to figure out why.


hey there guys !

so i've tested the script and it works on my test file :) many thanks and kudos!

but.... on my actual file- error appears.

i'm attaching 2 pics here- one to show the whole path of the png texture trying to replace, (no "." in the path etc.)

and the other pic is the error, seems to be when trying to substract the extension right? my scripting career has begun basically yesterday ! (thanks to you guys..)

any thoughts?

btw - for finding out the length for the loop i just go into materialeditor and select all materials to see how many the file currently has, right?



sry i'm not excelent in english .. XD

are you saying that the script interrupt before finish it job?

or just showing the error but everything is fine?

the for/next cycle i used ... started from "i=0"... meaning it is already the first cycle...

it was "trippy" for me, starting scripting...

example: "for i = 0 to 9" means TEN cycles

in each cyce the i vaule change from 0 to 9 > 0,1,2,3,4,5,6,7,8,9 

so, if you have like 15 materials, you have to set:

for i = 0 to 14

and you should get no more errors

(for i = 1 to 15 should work too, but i didn't tried it... )

if this is not going to work maybe i didn't understand well how index material work...

or maybe you was meaning something different...

(P.S. your screenshots were very small)




© 2014   Created by McNeel Admin.

Badges  |  Report an Issue  |  Terms of Service