SME: Get selected nodes (but only materials and that are not applied to scene)
if MatEditor.isOpen() != false AND maxOps.mtlDlgMode == #advanced then ( viewNode = sme.GetView (sme.activeView) view = trackViewNodes[#sme][(viewNode.name)] selNodeInterface = viewNode.getSelectedNodes() --get selected node in SME selNodeNames = sort(for m in selNodeInterface collect m.name) --collect all selected node/s names in SME selNodeMatsInSceneNames = sort(for o in sceneMaterials where o.name != undefined and FindItem selNodeNames o.name > 0 collect o.name) --collects only the names of materials in the scene theViewMats = for n = 1 to view.numsubs where (superClassOf view[n].reference == material) collect view[n].reference -- collects all mats in SME view ) viewNode view selNodeInterface selNodeNames selNodeMatsInSceneNames theViewMats
I've managed to get the names of selected nodes that are a scene material with:
selNodeMatsInSceneNames
And all the materials in the view in an array with:
theViewMats
I was wondering if it's possible to collect the selected nodes but only materials and also not applied to scene (that will be easy once I can only get the selected nodes and not the entire view)
The output of above code is:
<IObject:IFP_NodeViewImp> SubAnim:View1 #(<MixinInterface:Node>, <MixinInterface:Node>, <MixinInterface:Node>, <MixinInterface:Node>) #("02 - Default", "Map #4", "Material #47", "Material #48") #("Material #47") #(02 - Default:Standard, Material #47:Composite, Material #48:Standard, Material #74:Standard, Material #75:Standard, Material #76:Shell_Material)
Comments
Perfect. Here's that code in a different format
I shall incorporate this in my script and give you credit. I think you're the first one to get this done.. Others have tried ;)
This was my way..
Dirty as hell but it works 60% of the time all the time ;)
I shall test that more. It will be more reliable that just having to rely on finditem / deleteItem :)
You're a star for helping me out.
`
oki, finaly I think I found the way to get materials (not only names) :)
To get all selected materials in SME (in current view)
To get selected materials in SME but not used in scene:
let me know if this works in your scene
cheers,
Pixamoon