Material and Libraries management

Hi everyone

I'm creating a small script to manage material inside libraries and instance them in the slate editor.

But for now i'm stuck with two things:

- I can import a material in the slate viewport directly from a library but I don't find how can I select it and put it in the parameter editor

- I'd like to sort materials inside the library by alphabetical order

If any of you have any ideas, you are welcome :)

Comments

Comment viewing options

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

Thanks this will be helpful

Thanks this will be helpful :)

SugaR's picture

I said that because for the

I said that because for the parameter editor, the only thing I missed what this line:
sme.SetMtlInParamEditor mtl

So when I saw it in your post, I realized I was very tired and I could not think well enough, beacuse actually that was pretty simple... So you now, when you can't think well, just take a good night :)

Otherwise you clearly saved me a lot of research so thanks :)

barigazy's picture

...

SME have too many limitations ei. it's not exposed in mxs as it should.
On this forum you can find a few useful topics about SME if you're interested.
Anyway if you want to see all available SME methods just type in Listener

showinterface sme

barigazy

SugaR's picture

ok... Sometimes I think I

ok...
Sometimes I think I should just go to sleep...
Anyway a big thank for your help :)

barigazy's picture

...

Why? Now is time for action:)
Tell me is it my last post save your time or what? :)

barigazy

SugaR's picture

Thanks a lot ! Yes the

Thanks a lot !

Yes the parameter editor:
in slate editor material, you have 4 views:
- Material/Map Browser
- The viewport
- Navigator
- Parameter Editor (where you change your material properties)

So when I load a material in the viewport, I'd also like to select it and load it in the parameter editor

Anyway, thanks again for your help

barigazy's picture

...

example

b = Box material:(standard name:"BoxMtl" diffuse:red)
mtl = b.material
activView = sme.GetView 1
activView.CreateNode mtl [0,0]
sme.SetMtlInParamEditor mtl
if not sme.IsOpen() do sme.Open()

barigazy

barigazy's picture

...

In the "Parameter Editor"?
Anyway to sort materials in materialLibrary use this fn

fn sortMatLibMtlsByName mLib: =
(
	if (tmpLib = loadTempMaterialLibrary mLib) != undefined do
	(
		local mtls = sort (for m in tmpLib collect m.name)
		local newLib = MaterialLibrary()
		for n in mtls where (idx = findItem tmpLib tmpLib[n]) != 0 do append newLib tmpLib[idx]
		if newLib.count == tmpLib.count do saveTempMaterialLibrary newLib mLib
	)
)
sortMatLibMtlsByName mLib:@"c:\folder\anyMatlib.mat" -- change this filepath

barigazy

Comment viewing options

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