Get Material Properties

Hello

I'm new in max scripting and I'm trying to get a list all the material properties of the selected object.

This is my first attempt...

for prop in (getPropNames $.material) do
(
	getProperty $.material prop
)

...but no property were listed.
So, I tried to force the parameter name:

for prop in (getPropNames $.material) do
(
	getProperty $.material "Diffuse"
)

And again, no property are listed.

I did some test to check if I wrote the values correctly:

getProperty $.material "Diffuse"

And if I put the getProperty out of the loop, it works perfectly for this specific parameter.

I checked also the loop using a print function...

for prop in (getPropNames $.material) do
(
	print prop
)

...and it seems to work well, listing all the property names.

So... where I'm wrong?
I don't understand is why the getProperty row works only out of the "for prop" loop.

Someone can help me, please?

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
David_Lee's picture

Wow, now it works perfectly!

Wow, now it works perfectly!

Thanks barigazy! :)

barigazy's picture

try this

for prop in (getPropNames $.material) do
(
	format "% = %\n" (prop as string) (getProperty $.material prop)
)

bga

barigazy's picture

or

for prop in (getPropNames $.material) do
(
	print (getProperty $.material prop)
)
-- if you want to collect and then print
propList = for prop in (getPropNames $.material) collect (getProperty $.material prop)
for p in propList do print p

bga

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.