Notifications
Clear all

[Closed] Accessing vray attributes

Hello, I am a total nub to scripting. I’ve spent whole morning trying to find out how to list and edit vray material attributes trough script and to show them in 3ds max listener with no luck.

I know that “show $.material” will list default 3ds max materials, but when i try that with vrayMtl it says “Unknown property:“VrayMtl” in #selection” .

I saw in some scripts there are “#include” libraries at the top but i really dont know which to add or anything.

My final goal is to select multiple objects with vray materials and do mass change to an attribute on all of them at once. I already found one script that does that but I would like to learn to write it and to know how the gears work.

Thank you for your time.

15 Replies
abc = VrayMtl()
show abc
1 Reply
(@pexze)
Joined: 11 months ago

Posts: 0

God lord im an idiot, thank you.

I have one more question if u dont mind.
I have an array of vray materials and i want all of their outputs to connect to multi/sub object ids.
The problem is i dont know the syntax to connect material out to multi/sub object input.
And is it possible trough for loop to set how many id’s does a multi/sub object have?

I’ve browsed maxscript help documentation but with no luck. Cant even find a website with tutorials like w3school has for web developing. For any directions i would be greatfull. My goal is to learn all of this and not wait for good people to just give me solutions.

Thank you in advance.

What do you mean by multi/sub object?

mtl = multimaterial numsubs:arrayOfVrayMtls.count name:"arrayOfVrayMtls materials"
for i=1 to arrayOfVrayMtls.count do mtl.materialList[i] = arrayOfVrayMtls[i]
1 Reply
(@pexze)
Joined: 11 months ago

Posts: 0

I am making a script that will pickup all the vray materials in the scene, put them in one multi/sub material and then output of that material connect to input of vray wrap material.

Atm im i’ve come up with this


select (for o in geometry where o.mat.category == #vray collect o)
for i = 1 to selection.count do 
(
    initialise multi/sub object    <- dont know this
    o[i].material.output connect to id[i] input of multi/sub object   <- this is the part i dont know how to do. 
}

and now  multi/sub material like on image connect to vrayMtlWrapper

(
mtls = #()
for c in material.classes do join mtls (getClassInstances c)
mtls = for m in mtls where m.category == #Vray collect m
mmtl = Multimaterial numsubs:mtls.count
mmtl.materiallist = mtls
mtlWrapper = VRayMtlWrapper baseMtl:mmtl

meditMaterials[1] = mtlWrapper
)
2 Replies
(@pexze)
Joined: 11 months ago

Posts: 0

Im trying to wrap my head around this. But it works, i’ve learned so much from this small script you wrote lol. Btw in first line mtls = #() does that initialises empty array or some other type, and what does # do exacly?
Do you know any place where i can learn from scratch, like a book or tutorial for scripting because this googling and scraping code from web pages isnt doing allot for my knowledge. I’ve read maxscript help but descriptions there are a bit too general.

Thank you allot again, i’ve been at this for a week now.

(@pexze)
Joined: 11 months ago

Posts: 0

Serejah, could you tell me how to get vray2sidedMtl, vrayBlendMtl, vrayLightMtl.
i’ve tried with

mtls = for m in mtsl where m.category == #vray2sided collect m
                                 or                                             == #vrayBlend collect m

but it keeps returning error. I want to try to connect those materials too to the wrapper, or to a new wrapper doesn matter

Or could you direct me to where i can see vray material tags for those types.

But what’s wrong with the maxscript reference? It’s unlikely that you can find any better explanation of maxscript basics with examples (except this forum).

I guess I’m not used to it, so having a hard time searching in it :). I was hopping to find some website like w3 school or something similar with step by step so I can ease into the whole thing.

I’ve come up with a problem in my logic and how i’ve explained it, the way you wrote it it collects all of the vray materials ever created in the project even those that are not in use. I’ve changed it a bit to collect only those in the scene, gonna paste it here for any1 that comes to this problem too.

(
	        mtls = #()
		sceneMtls = for mat in SceneMaterials collect mat
		mtls = for m in sceneMtls where m.category == #Vray collect m
		mmtl = Multimaterial numsubs:mtls.count
		mmtl.materiallist = mtls
		mtlWrapper = VRayMtlWrapper baseMtl:mmtl
		mtlWrapper.name = "Wrappsallot"
		meditMaterials[1] = mtlWrapper
	    )

vray2sidedMtl.category returns #standard :argh:

mtls = for m in mtsl where classof m ==  vray2sidedMtl collect m
1 Reply
(@pexze)
Joined: 11 months ago

Posts: 0

Ah yes I just loged in to tell you that i found it after experimenting. The problem is now that when i use #standard for that i get an error for “Unable to covert: DefaultVRaySky:VraySky to type:Material”

is it possible to write exception in for loot like

mtsl = for m in sceneMtls where m.category == #standard except m.category VRaySky collect m 

simple


mtsl = for m in sceneMtls where m.category == #standard [B]and superclassof m == material[/B] collect m




1 Reply
(@pexze)
Joined: 11 months ago

Posts: 0

Aah superclassof, thank you, ive learned allot. I wont bother you anymore.

Update on my predicament. With the help of Serejah he solved my problem

Ive conected all my materials but the problem was they weren’t updated in the scene so this was the solution

for s in scenematerials where superclassof s == material do 
	(	
		wr = VRayMtlWrapper baseMtl:s
		wr.name = s.name + " wrapper"
		replaceInstances s wr
		wr.baseMtl = s
	)