Notifications
Clear all

[Closed] (SME.GetNode X).selected ?

So I’m curious if anyone has actually found any foolproof way to work with Slate/SME in MAXScript? I’ve found several discussions where Denis has shared useful tidbits for accessing the actual nodes via trackview… but even with that I’m finding it nearly impossible to determine what nodes are selected in a slate view.

Is something wrong with the logic below or is this a full-blown bug:

sme.Open() 
testname = "MXS Selection Test"
existing  = sme.GetViewByName testname
if existing > 0 then (
	sme.DeleteView existing false
)
sme.activeView  =  (sme.CreateView testname)
v = sme.activeView
view = sme.GetView v
pos = [0,0]
numsubs = 10
MultiMat = MultiMaterial name:"multimaterial" numsubs:numsubs
view.CreateNode MultiMat pos 
 for m = 1 to numsubs do (
	 mat = multiMat.materialList[m] 
	 mat.diffuseMap = checker name:("tex"+m as string) 
	 mat.name = ("Mat "+ (m as string))
	 multiMat.names[m] = ("Mat "+ (m as string))
)
view.SetSelectedNodes (#((multiMat.materialList[random 1 numsubs])))
numNodes = view.GetNumNodes()
for n = 1 to numNodes do (
	nd = view.GetNode n
	if nd.selected == true then (
		ref = trackViewNodes[#sme][v][n].reference
		format "% > % > % 
" n nd ref
	)
)

If you run this code, it should create a new view and add a multimaterial into the view with 10 submaterials each with a Checker texture in the diffuse. It should also set the selected nodes in the view to a single one of the standard materials. However, at the end, it is always the last checker texture that is determined to be selected.

Bad logic? Bug? Wrong methods/properties?

I’m currently testing in Max 2015… but I’ve returning to a function that has been bugged for a few years now (maybe since Slate came out as far as I remember…)

2 Replies

Not sure the issue, but see my modified code:

(
    sme.Open() 
    testname = "MXS Selection Test"
    existing  = sme.GetViewByName testname
    if existing > 0 then (
        sme.DeleteView existing false
    )
    sme.activeView  =  (sme.CreateView testname)
    v = sme.activeView
    view = sme.GetView v
    pos = [0,0]
    numsubs = 10
    MultiMat = MultiMaterial name:"multimaterial" numsubs:numsubs
    view.CreateNode MultiMat pos 
     for m = 1 to numsubs do (
         mat = multiMat.materialList[m] 
         mat.diffuseMap = checker name:("tex"+m as string) 
         mat.name = ("Mat "+ (m as string))
         multiMat.names[m] = ("Mat "+ (m as string))
    )
    view.SetSelectedNodes (#((multiMat.materialList[random 1 numsubs])))
    format "Selected Node | %

" (view.getSelectedNodes())[1].name
    numNodes = view.GetNumNodes()
    for n = 1 to numNodes do (
        nd = view.GetNode n
        format "% | %
" nd.name nd.selected
        if nd.selected == true then (
            ref = trackViewNodes[#sme][v][n].reference
            format "% > % > % 
" n nd ref
        )
    )
)

I added 2 formats to output what is selected using different calls both of which return the correct information. It is the if test that returns incorrect information.

-Eric

Thanks Eric.

Maybe I’m too tired… but it looks to be that this means that all of my previous readings about using the trackview for getting the actual material/texture nodes is not what I thought.

The question then is how do you find the actually mat/tex node in relation to the sme nodes? The only thing popping in my mind is comparing names–but that is simply not trustworthy at all.

In my particular case, I’d like to get the actual tex/mat nodes that happen to be selected.