SME Get Selected Materials
Version:
v0.10
Date Updated:
09/02/2015 This script is useful only for script writers.
This is just simple function to get selected materials / textures / controllers from active view in SME.
Function returns materials :) - not names of materials.
function SMEGetSelMats = ( viewNode = sme.GetView (sme.activeView) smeSelMats = #() for n = 1 to trackViewNodes[#sme][(sme.activeView)].numSubs do ( m = trackViewNodes[#sme][(sme.activeView)][n].reference b = viewNode.GetNodeByRef m if b.selected do append smeSelMats m ) return smeSelMats ) -- do something here print (SMEGetSelMats())
I've got message - it doesn't work with 2012. If anybody has 2012, please test and let me know
Enjoy
Pixamoon
Comments
Just to expand on this more
Just to expand on this more :)
notes to comment:
`
hey hey,
I saw that on AD forum and CGSociety forum but it didn't work for me because:
view.GetNode n
"n" index is different than "n" index in:
trackViewNodes[#sme][v][n]
I noticed that index can be the same on beginning only - till double click on node (to load it into right panel). After that index is moved.
That's why we can't get selected material from selected node by
if (view.GetNode n).selected do mat = trackViewNodes[#sme][v][n].reference
But your post was a big step to find this solution :) Thanks!
Best,
Pixammon
Thanks for sharing. I've used
Thanks for sharing. I've used a similar set of logic for a while but ended up simply abandoning it. You might want to look at http://forums.autodesk.com/t5/programming/sme-maxscript-access/m-p/5633962 because the results seem to be bugged in many cases. I noticed that the results were sometimes correct, but just as often totally wrong.
AD has confirmed the bug. It's annoying, but at least as of June it was still broken in all versions of Max. I haven't tested in 2016 SP1 yet.
_______________________
Shawn Olson
Developer of Wall Worm