ScriptSpot

Forum topic · General Scripting

Naming a material or map

By Script_Butler · 2012-01-31

Description

Hi all

Really simple question, and no doubt my first of many for my new script idea!

I've written script to put a VrayHDRI map in to slots 1 & 2 of the material editor but I can't figure out how to name these maps.

How do I script that?

Cheers

Script_Butler.

Comments (12)

Thanks

Script_Butler · 2012-02-06

Hi Anubis.

thanks for the link, and the script.

It's a similar thing to what i wanted. It was just the piece of script that copies an image string in to a map slot somewhere.

I have creted the rest of my script, wiring parameters and stuff together.

I will see if i can pich the part i need from your and implement it in to mine.

I'll let you know hw i get on. I would definitely prefer just tips and help. I never want my ideas to be written fully for me!

Bookmarked.

I just can't do it!

Script_Butler · 2012-02-06

How can i add in a line that copies image1.filename and image2.filename to the texmap: in a HDRI map in the material editor?

I've searched and just can 't figure it out! It's so annoying!

VRay Reference

Anubis · 2012-02-03

Ok, I find something useful for you, just bookmark this page:
http://vraydoc.narod.ru/vray150sp1/objects_maxscript.htm

Here is the VRayHDRI map properties:

.HDRIMapName (Spin) : filename
.multiplier (Spin) : float
.renderMultiplier (Spin) : float
.mapType (Spin) : integer
.horizontalRotation (Spin) : angle
.verticalRotation (Spin) : angle
.horizontalFlip (Spin) : boolean
.verticalFlip (Spin) : boolean
.mapChannel (Spin) : integer
.gamma (Spin) : float

So, obviously

HDRIMapName

is what you look for.

Well, if I get the whole task, then this may help:

rollout roVRTool "Your Tool Name"
(
	local image1, image2
	
	button get_image1 "Pick HDRI File 1"
	button get_image2 "Pick HDRI File 2"
	button btn_Setup  "Setup"
	
	on get_image1 pressed do
	(image1 = selectBitmap caption:"Get Image File")
	
	on get_image2 pressed do
	(image2 = selectBitmap caption:"Get Image File")
	
	on btn_Setup pressed do
	(
		if image1 == undefined or \
		image2 == undefined then
			messageBox "You need 2 images!"
		else
		(
			map1 = VRayHDRI name:"HDRI GI" \
			HDRIMapName:(image1.fileName)

			map2 = VRayHDRI name:"HDRI Reflection" \
			HDRIMapName:(image2.fileName)

			vrl1 = VRayLight name:"Dome GI" \
			type:1 size0:150 size1:100 \
			pos:[-10,0,0] texmap:map1

			vrl2 = VRayLight name:"Dome Reflection" \
			type:1 size0:150 size1:100 \
			pos:[10,0,0] texmap:map2
		)
	)
)
createDialog roVRTool

But after all, I can just encourage you to search more ;-)

I'm so certain i tried that and it didn't work.

Script_Butler · 2012-02-03

I'll try this later again. I probably had a small typo or something.

Cheers.

Next question!

Script_Butler · 2012-02-03

In my script i have a button to get an image file from a local drive. Once this file is selected it pastes the path in to an edittext box.



button get_image "Pick HDRI File" width:140
edittext bmp_name "File" text:"" 

Then i have the following code.


on get_image pressed do
(
pick_image = selectBitmap caption:"Get Image File"
if pick_image != undefined then bmp_name.text = pick_image.filename

I then have a button that is pressed that creates two HDRI maps and I want these HDRI maps to load in the image that the user has selected in the above coding.

How can i get this path string to appear in a HDRI map that is created through this script?

I hope that makes sense.

Perfect

Script_Butler · 2012-02-01

Thanks again Anubis.

I tried all manner of things by looking at other scripts i have but just couldn't get it!

I'm sure i'll be posting more questions about this script soon, it's going to get complicated.

Cheers.

here is...

Anubis · 2012-02-01

if your map is already in the ME slot and want to rename it:

meditMaterials[1].name = "New Name"

you can name your materials and/or maps in the creation process as well, for example, next code will create standard material with name Foo and will add it to the second ME slot:

meditMaterials[2] = standard name:"Foo"

Further to this

Script_Butler · 2012-02-02

Hi Anubis.

Further to this I've changed my script a bit!

I've got a button that when you click it, it enables the user to select an image file on their computer. The path string is then pasted in to a edittext underneath.

How can i get this path to be put in to the .texmap of a Vray dome light?

I have a create button with the intention of it creating a VRayDomeLight with this texture added in to it automatically.

I hope that makes sense.

i not use vray

Anubis · 2012-02-02

so cannot help with anything concrete.
you s'd find the name of the property of your vr-map.
for example, create your map in 1st ME slot and print it properties to the Listener with show() function:

show meditMaterials[1]

it will show their names and their type/value.
keep in mind that there may have and nested values, which should research too.

Script_Butler · 2012-02-02

Heres my code snippit for this idea.

on btn_Setup pressed do
(
meditmaterials[1] = VRayHDRI name: "HDRI GI"()
meditmaterials[2] = copy meditMaterials[1]
VRayLight type:1 size0:150 size1:100 pos:[-10,0,0] isSelected:off name: "Dome GI" texmap:meditmaterials[1]
VRayLight type:1 size0:150 size1:100 pos:[10,0,0] isSelected:off name: "Dome Reflection" texmap:meditmaterials[2]

So it creates the first material, copies it, then creates a light with the first material in the texture slot and copies that light and puts the second material in it's texture slot.

All I need is for the second material to have a different name.

It seems so simple to me but i just can;t do it!! It's infuriating!

Anubis · 2012-02-02

on btn_Setup pressed do
(
meditmaterials[1] = VRayHDRI name: "HDRI GI"
meditmaterials[2] = copy meditMaterials[1]

meditmaterials[2].name = "Some Other Name"

--...the rest is the same
)

Hi again

Anubis · 2012-02-03

Well, as i said, i not work with VRay.
Check this tool - VrayHDRITool
(or wait for some vr-user reply)