Code Improvement, vray realworld texture
Hi!
I know that It's possible to reduce this mess of code to two simple lines, but I simply don't have the knowhow.
My script toggle's on or off the realworld scale and sets the values for it. I would like to make it selection based, but I couldn't change the getclassinstances into a selection.
I also want it to check all the map slots for bitmaptexture, initially I tried to call the vray class into the for statement but that was beyond my grasp, so I then tried putting the vray class names into an array and adding to the getclassinstances, but isntead of course it didn't work so I copied and pasted it 16 times!! lol
Any help is appreciated.
if no help, no worries, maybe someone else could use this code. I know I searched a while to find anything related.
if vraywindowrollout != undefined do destroyDialog vraywindowrollout try destroyDialog vraywindowrollout catch() ( rollout vraywindowrollout " Make windows" width:162 height:173 ( Group "" ( label lbl "Make a selection and go" align:#left checkbox RW_checkbox "Turn on Realworld Scale?" align:#left checked:true spinner RW_width "Width" align:#left enabled:true range:[-1200,1200,120] type:#worldunits fieldwidth:40 spinner RW_height "Height" align:#left enabled:true range:[-1200,1200,120] type:#worldunits fieldwidth:40 button run_script "GO GO GO!" toolTip:"Press this button to GO." align:#center ) --end group --for statement needed here for selection? --for o in selection where (o.material!=undefined) collect o.material on run_script pressed do ( --string $TEXarray[16] = {".texmap_diffuse", ".texmap_reflection", ".texmap_refraction", ".texmap_bump", ".texmap_reflectionGlossiness", ".texmap_refractionGlossiness", ".texmap_refractionIOR", ".texmap_displacement", ".texmap_translucent", ".texmap_environment", ".texmap_hilightGlossiness", ".texmap_reflectionIOR", ".texmap_opacity", ".texmap_roughness", ".texmap_anisotropy", ".texmap_anisotropy_rotation"} for o in getclassinstances VRayMtl where o.texmap_diffuse != undefined and classof o.texmap_diffuse == bitmaptexture do ---get all vraymtl w texmap_diffuse ( o.texmap_diffuse.coords.realWorldScale = RW_checkbox.state o.texmap_diffuse.coords.realWorldWidth = RW_width.value o.texmap_diffuse.coords.realWorldHeight = RW_height.value )--end for --string $TEXarray[16] = {".texmap_diffuse", ".texmap_reflection", ".texmap_refraction", ".texmap_bump", ".texmap_reflectionGlossiness", ".texmap_refractionGlossiness", ".texmap_refractionIOR", ".texmap_displacement", ".texmap_translucent", ".texmap_environment", ".texmap_hilightGlossiness", ".texmap_reflectionIOR", ".texmap_opacity", ".texmap_roughness", ".texmap_anisotropy", ".texmap_anisotropy_rotation"} for o in getclassinstances VRayMtl where o.texmap_reflection != undefined and classof o.texmap_reflection == bitmaptexture do ---get all vraymtl w texmap_diffuse ( o.texmap_reflection.coords.realWorldScale = RW_checkbox.state o.texmap_reflection.coords.realWorldWidth = RW_width.value o.texmap_reflection.coords.realWorldHeight = RW_height.value )--end for --string $TEXarray[16] = {".texmap_diffuse", ".texmap_reflection", ".texmap_refraction", ".texmap_bump", ".texmap_reflectionGlossiness", ".texmap_refractionGlossiness", ".texmap_refractionIOR", ".texmap_displacement", ".texmap_translucent", ".texmap_environment", ".texmap_hilightGlossiness", ".texmap_reflectionIOR", ".texmap_opacity", ".texmap_roughness", ".texmap_anisotropy", ".texmap_anisotropy_rotation"} for o in getclassinstances VRayMtl where o.texmap_refraction != undefined and classof o.texmap_refraction == bitmaptexture do ---get all vraymtl w texmap_diffuse ( o.texmap_refraction.coords.realWorldScale = RW_checkbox.state o.texmap_refraction.coords.realWorldWidth = RW_width.value o.texmap_refraction.coords.realWorldHeight = RW_height.value )--end for --string $TEXarray[16] = {".texmap_diffuse", ".texmap_reflection", ".texmap_refraction", ".texmap_bump", ".texmap_reflectionGlossiness", ".texmap_refractionGlossiness", ".texmap_refractionIOR", ".texmap_displacement", ".texmap_translucent", ".texmap_environment", ".texmap_hilightGlossiness", ".texmap_reflectionIOR", ".texmap_opacity", ".texmap_roughness", ".texmap_anisotropy", ".texmap_anisotropy_rotation"} for o in getclassinstances VRayMtl where o.texmap_bump != undefined and classof o.texmap_bump == bitmaptexture do ---get all vraymtl w texmap_diffuse ( o.texmap_bump.coords.realWorldScale = RW_checkbox.state o.texmap_bump.coords.realWorldWidth = RW_width.value o.texmap_bump.coords.realWorldHeight = RW_height.value )--end for --string $TEXarray[16] = {".texmap_diffuse", ".texmap_reflection", ".texmap_refraction", ".texmap_bump", ".texmap_reflectionGlossiness", ".texmap_refractionGlossiness", ".texmap_refractionIOR", ".texmap_displacement", ".texmap_translucent", ".texmap_environment", ".texmap_hilightGlossiness", ".texmap_reflectionIOR", ".texmap_opacity", ".texmap_roughness", ".texmap_anisotropy", ".texmap_anisotropy_rotation"} for o in getclassinstances VRayMtl where o.texmap_reflectionGlossiness != undefined and classof o.texmap_reflectionGlossiness == bitmaptexture do ---get all vraymtl w texmap_diffuse ( o.texmap_reflectionGlossiness.coords.realWorldScale = RW_checkbox.state o.texmap_reflectionGlossiness.coords.realWorldWidth = RW_width.value o.texmap_reflectionGlossiness.coords.realWorldHeight = RW_height.value )--end for --string $TEXarray[16] = {".texmap_diffuse", ".texmap_reflection", ".texmap_refraction", ".texmap_bump", ".texmap_reflectionGlossiness", ".texmap_refractionGlossiness", ".texmap_refractionIOR", ".texmap_displacement", ".texmap_translucent", ".texmap_environment", ".texmap_hilightGlossiness", ".texmap_reflectionIOR", ".texmap_opacity", ".texmap_roughness", ".texmap_anisotropy", ".texmap_anisotropy_rotation"} for o in getclassinstances VRayMtl where o.texmap_refractionGlossiness != undefined and classof o.texmap_refractionGlossiness == bitmaptexture do ---get all vraymtl w texmap_diffuse ( o.texmap_refractionGlossiness.coords.realWorldScale = RW_checkbox.state o.texmap_refractionGlossiness.coords.realWorldWidth = RW_width.value o.texmap_refractionGlossiness.coords.realWorldHeight = RW_height.value )--end for --string $TEXarray[16] = {".texmap_diffuse", ".texmap_reflection", ".texmap_refraction", ".texmap_bump", ".texmap_reflectionGlossiness", ".texmap_refractionGlossiness", ".texmap_refractionIOR", ".texmap_displacement", ".texmap_translucent", ".texmap_environment", ".texmap_hilightGlossiness", ".texmap_reflectionIOR", ".texmap_opacity", ".texmap_roughness", ".texmap_anisotropy", ".texmap_anisotropy_rotation"} for o in getclassinstances VRayMtl where o.texmap_refractionIOR != undefined and classof o.texmap_refractionIOR == bitmaptexture do ---get all vraymtl w texmap_diffuse ( o.texmap_refractionIOR.coords.realWorldScale = RW_checkbox.state o.texmap_refractionIOR.coords.realWorldWidth = RW_width.value o.texmap_refractionIOR.coords.realWorldHeight = RW_height.value )--end for --string $TEXarray[16] = {".texmap_diffuse", ".texmap_reflection", ".texmap_refraction", ".texmap_bump", ".texmap_reflectionGlossiness", ".texmap_refractionGlossiness", ".texmap_refractionIOR", ".texmap_displacement", ".texmap_translucent", ".texmap_environment", ".texmap_hilightGlossiness", ".texmap_reflectionIOR", ".texmap_opacity", ".texmap_roughness", ".texmap_anisotropy", ".texmap_anisotropy_rotation"} for o in getclassinstances VRayMtl where o.texmap_displacement != undefined and classof o.texmap_displacement == bitmaptexture do ---get all vraymtl w texmap_diffuse ( o.texmap_displacement.coords.realWorldScale = RW_checkbox.state o.texmap_displacement.coords.realWorldWidth = RW_width.value o.texmap_displacement.coords.realWorldHeight = RW_height.value )--end for --string $TEXarray[16] = {".texmap_diffuse", ".texmap_reflection", ".texmap_refraction", ".texmap_bump", ".texmap_reflectionGlossiness", ".texmap_refractionGlossiness", ".texmap_refractionIOR", ".texmap_displacement", ".texmap_translucent", ".texmap_environment", ".texmap_hilightGlossiness", ".texmap_reflectionIOR", ".texmap_opacity", ".texmap_roughness", ".texmap_anisotropy", ".texmap_anisotropy_rotation"} for o in getclassinstances VRayMtl where o.texmap_translucent != undefined and classof o.texmap_translucent == bitmaptexture do ---get all vraymtl w texmap_diffuse ( o.texmap_translucent.coords.realWorldScale = RW_checkbox.state o.texmap_translucent.coords.realWorldWidth = RW_width.value o.texmap_translucent.coords.realWorldHeight = RW_height.value )--end for --string $TEXarray[16] = {".texmap_diffuse", ".texmap_reflection", ".texmap_refraction", ".texmap_bump", ".texmap_reflectionGlossiness", ".texmap_refractionGlossiness", ".texmap_refractionIOR", ".texmap_displacement", ".texmap_translucent", ".texmap_environment", ".texmap_hilightGlossiness", ".texmap_reflectionIOR", ".texmap_opacity", ".texmap_roughness", ".texmap_anisotropy", ".texmap_anisotropy_rotation"} for o in getclassinstances VRayMtl where o.texmap_environment != undefined and classof o.texmap_environment == bitmaptexture do ---get all vraymtl w texmap_diffuse ( o.texmap_environment.coords.realWorldScale = RW_checkbox.state o.texmap_environment.coords.realWorldWidth = RW_width.value o.texmap_environment.coords.realWorldHeight = RW_height.value )--end for --string $TEXarray[16] = {".texmap_diffuse", ".texmap_reflection", ".texmap_refraction", ".texmap_bump", ".texmap_reflectionGlossiness", ".texmap_refractionGlossiness", ".texmap_refractionIOR", ".texmap_displacement", ".texmap_translucent", ".texmap_environment", ".texmap_hilightGlossiness", ".texmap_reflectionIOR", ".texmap_opacity", ".texmap_roughness", ".texmap_anisotropy", ".texmap_anisotropy_rotation"} for o in getclassinstances VRayMtl where o.texmap_hilightGlossiness != undefined and classof o.texmap_hilightGlossiness == bitmaptexture do ---get all vraymtl w texmap_diffuse ( o.texmap_hilightGlossiness.coords.realWorldScale = RW_checkbox.state o.texmap_hilightGlossiness.coords.realWorldWidth = RW_width.value o.texmap_hilightGlossiness.coords.realWorldHeight = RW_height.value )--end for --string $TEXarray[16] = {".texmap_diffuse", ".texmap_reflection", ".texmap_refraction", ".texmap_bump", ".texmap_reflectionGlossiness", ".texmap_refractionGlossiness", ".texmap_refractionIOR", ".texmap_displacement", ".texmap_translucent", ".texmap_environment", ".texmap_hilightGlossiness", ".texmap_reflectionIOR", ".texmap_opacity", ".texmap_roughness", ".texmap_anisotropy", ".texmap_anisotropy_rotation"} for o in getclassinstances VRayMtl where o.texmap_reflectionIOR != undefined and classof o.texmap_reflectionIOR == bitmaptexture do ---get all vraymtl w texmap_diffuse ( o.texmap_reflectionIOR.coords.realWorldScale = RW_checkbox.state o.texmap_reflectionIOR.coords.realWorldWidth = RW_width.value o.texmap_reflectionIOR.coords.realWorldHeight = RW_height.value )--end for --string $TEXarray[16] = {".texmap_diffuse", ".texmap_reflection", ".texmap_refraction", ".texmap_bump", ".texmap_reflectionGlossiness", ".texmap_refractionGlossiness", ".texmap_refractionIOR", ".texmap_displacement", ".texmap_translucent", ".texmap_environment", ".texmap_hilightGlossiness", ".texmap_reflectionIOR", ".texmap_opacity", ".texmap_roughness", ".texmap_anisotropy", ".texmap_anisotropy_rotation"} for o in getclassinstances VRayMtl where o.texmap_opacity != undefined and classof o.texmap_opacity == bitmaptexture do ---get all vraymtl w texmap_diffuse ( o.texmap_opacity.coords.realWorldScale = RW_checkbox.state o.texmap_opacity.coords.realWorldWidth = RW_width.value o.texmap_opacity.coords.realWorldHeight = RW_height.value )--end for --string $TEXarray[16] = {".texmap_diffuse", ".texmap_reflection", ".texmap_refraction", ".texmap_bump", ".texmap_reflectionGlossiness", ".texmap_refractionGlossiness", ".texmap_refractionIOR", ".texmap_displacement", ".texmap_translucent", ".texmap_environment", ".texmap_hilightGlossiness", ".texmap_reflectionIOR", ".texmap_opacity", ".texmap_roughness", ".texmap_anisotropy", ".texmap_anisotropy_rotation"} for o in getclassinstances VRayMtl where o.texmap_roughness != undefined and classof o.texmap_roughness == bitmaptexture do ---get all vraymtl w texmap_diffuse ( o.texmap_roughness.coords.realWorldScale = RW_checkbox.state o.texmap_roughness.coords.realWorldWidth = RW_width.value o.texmap_roughness.coords.realWorldHeight = RW_height.value )--end for --string $TEXarray[16] = {".texmap_diffuse", ".texmap_reflection", ".texmap_refraction", ".texmap_bump", ".texmap_reflectionGlossiness", ".texmap_refractionGlossiness", ".texmap_refractionIOR", ".texmap_displacement", ".texmap_translucent", ".texmap_environment", ".texmap_hilightGlossiness", ".texmap_reflectionIOR", ".texmap_opacity", ".texmap_roughness", ".texmap_anisotropy", ".texmap_anisotropy_rotation"} for o in getclassinstances VRayMtl where o.texmap_anisotropy != undefined and classof o.texmap_anisotropy == bitmaptexture do ---get all vraymtl w texmap_diffuse ( o.texmap_anisotropy.coords.realWorldScale = RW_checkbox.state o.texmap_anisotropy.coords.realWorldWidth = RW_width.value o.texmap_anisotropy.coords.realWorldHeight = RW_height.value )--end for --string $TEXarray[16] = {".texmap_diffuse", ".texmap_reflection", ".texmap_refraction", ".texmap_bump", ".texmap_reflectionGlossiness", ".texmap_refractionGlossiness", ".texmap_refractionIOR", ".texmap_displacement", ".texmap_translucent", ".texmap_environment", ".texmap_hilightGlossiness", ".texmap_reflectionIOR", ".texmap_opacity", ".texmap_roughness", ".texmap_anisotropy", ".texmap_anisotropy_rotation"} for o in getclassinstances VRayMtl where o.texmap_anisotropy_rotation != undefined and classof o.texmap_anisotropy_rotation == bitmaptexture do ---get all vraymtl w texmap_diffuse ( o.texmap_anisotropy_rotation.coords.realWorldScale = RW_checkbox.state o.texmap_anisotropy_rotation.coords.realWorldWidth = RW_width.value o.texmap_anisotropy_rotation.coords.realWorldHeight = RW_height.value )--end for --)--end Do ) --end Do run_script )--end rollout )--end if createdialog vraywindowrollout width:190 height:185 --pos:[1150, 175]
Comments
...
I did'nt test this but concept is good. Check it out
bga
Fantastic!
Works great, I just edited a little and it works fantastic. Best of all I think I know how it works :-)
If I get around to it I'll put in some toggles for change all values/don't change
Maybe blur/tiling angle etc...
...
First thing first.
You changed this line
for o in selection where o.mat != undefined do ...
to this
for o in selection where o.maxobject != undefined do ...
In my code i check if selected object have assigned material ei. U can use
o.mat -- or o.material
It's the same.
If you want to check selected object if is valid then use
for o in selection where isValidNode o and o.mat != undefined do ...
Another thing in this line U use property "UnknownUndefined". I never saw this before and this property probably not exist.
for t in texture where t.UnknownUndefined != undefined do...
It's better to check only "filename" property. Something like this.
for t in texture where isKindOf t.filename string do...
I hope that this is the right way ;)
bga
You are very wise, yes I
You are very wise, yes I changed them as I was unsure what .mat was, when I removed the .mat the script triggered the != undefined with a little test scene and the max object dialog box. I did a search for .mat and didn't find it, so assumed it was an empty variable|name (print o and print.mat showed the same values).
I then inferred that .filename was also empty name, but I wasn't sure what I was checking for undefined, so I made up a name:-)
I will change back now that I know what they are.
If o.mat is not undefined then wouldn't that cover the max object type, so no need for isValidNode?
...
Yup. In this case you not need "isValidNode" check function.
This tool will only process object with assigned material and also this material
can be any material (not only VRayMtl).
Bitmaptexture is important here not material type.
Now you see that code is short and clean.
Next time try to ask first before you make up new variable or property name :)
Cheers!
bga