[Closed] get selected mtl from Slate Material Editor
Hi,
I’d like to retrieve the selected materials from the sme.
Until now I can only loop through nodes with the sme object but getting a node gives me access to a mixin interface containing a “name” and a “position” method
s = sme.GetView 1
i = s.GetNode 1
showInterface i
returns :
<MixinInterface:Node>
Interface: Node
Properties:
.name : string : Read|Write
.position : point2 by value : Read|Write
Methods:
Actions:
I can also get some information through the trackview but I can’t get the selection information.
Do you know if it’s possible and how ?
thx
You can get the Material which is in the editor (has been doubled clicked on)
SME.GetMtlinParamEditor()
U can look my earlier posts on scriptspot.
Maybe some of these can help
How to loop the materials in the Slate Material Editor
Change map type
Hi, thanks for your answers, but :
@Dave : The problem is that I want to get a multiple selection so this wont work in my case
@gazybara : I’ve read your script and while it loop through the material nodes I cannot find a way to retrieve only the selected one.
There is a method in the doc from the nodeview interface that is related to the selection but it’s only for removal :
IFP_NodeViewImp : IObject Interface: NodeView
<void>[i]DeleteSelection/i Deletes the selected nodes.
I may have to work with the objects if there is no solution.
This feature is added in max2014
<Interface by value array>GetSelectedNodes()
bad… max 2014 extended in this matter. now it has full selection sme node support… in earlier versions the only thing we have is DeleteSelection().
so try to use… how?
#1 get all nodes
#2 delete selected
#3 get nodes after
#4 compare before and deletion
#5 return every back
sounds not too easy? but it’s pretty easy. let me write a function
guys:
could you run this code and tell what it returns for you and what version of max you use:
(
while sme.getnumviews() > 0 do sme.deleteview 1 off
sme.createview "v1"
(sme.getview 1).createnode (standard()) [0,0]
(sme.getview 1).createnode (standard()) [180,0]
for k=1 to (sme.getview 1).getnumnodes() collect (sme.getview 1).getnode k
)
thanks.
Something like this
fn sme_getSelectedNodes =
(
local viewNode = sme.GetView (sme.activeView)
local view = trackViewNodes[#sme][(viewNode.name)]
if view.numsubs > 0 do
(
allMats = for n = 1 to view.numsubs collect view[n].reference
viewNode.DeleteSelection()
currentNodeNames = for n = 1 to view.numsubs collect (view[n].reference.name)
max undo
for n in allMats where findItem currentNodeNames n.name == 0 collect n
)
)
Nice workaround Denis! It seems a bit dirty indeed but I’ll give it a try toomorrow.