Notifications
Clear all

[Closed] get selected mtl from Slate Material Editor

Max 2014 and Max2013 x64

#(<MixinInterface:Node>, <MixinInterface:Node>)

Max 2011 x32

#(<MixinInterface:Node>, undefined)

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

this is a bug what i want to be confirmed.
max <2013 returns only first node of a view… it’s very hard to get all view nodes.
the bug was fixed in 2013+

as i understood we need to get selected in SME nodes. not in the tyrackview

and. what if UNDO set to disabled? …

Just change last line of the function

for n = 1 to viewNode.GetNumNodes() where findItem currentNodeNames (smeNode = viewNode.GetNode n).name == 0 collect smeNode

Enable undo then run the fn

Compact version

fn sme_getSelectedNodes _return:#sme_nodes = 
 (
 	   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()
 		   names = for n = 1 to view.numsubs collect (view[n].reference.name) ; max undo
 		 if _return == #sme_mats then (for n in allMats where findItem names n.name == 0 collect n)
 		 else (for n = 1 to viewNode.GetNumNodes() where findItem names (smeNode = viewNode.GetNode n).name == 0 collect smeNode)
 	   )
 )

what is about if the function has to be used inside another undoable function?

i just want to say that “max undo” is not right way to revert all back

You first suggested this method. Now it’s my “fault” because the function have disadvantages

3 Replies
(@denist)
Joined: 11 months ago

Posts: 0

i said: “return everything back”
i didn’t say “undo”

(@gazybara)
Joined: 11 months ago

Posts: 0

But how to return deleted sme nodes?
BTW I not see any useful method that’s supports sme in versions below 2014.

(@denist)
Joined: 11 months ago

Posts: 0

is means it the time to look at theHold

I knew from the beginning that’s what you mean.
I never used theHold before. That’s why I try to avoid it.
Your next post will be number 6666

…deleted

because the post was 6666th

1 Reply
(@gazybara)
Joined: 11 months ago

Posts: 0

It’s not 3 but 4 sixes. That is not dangerous

@Denis : 2012 x64 version : #(<MixinInterface:Node>, undefined)
I’ll take a look at the hold if I have a moment but it the way you speak of it doesn’t give me courage. Thanks for the workaround anyway

@gazybara : thanks for the code, I've learned one or two things about compact code :). As I just need the name of the materials selected trackview retrieving is ok. Still, I tried the node method and it doesn't seems to work quite well : 
  • If I select a material and launch the script it fails with the node selected being undefined through “viewNode.GetNode n”
  • If I select some materials the deselect all by clicking in the view grid and run the scripts, it gives me back my selection and fails

the deleted node seems to be back but not fetchable could you tell me if you got the same results ?

Ok, another thing I got, placed in a flat file #sme_mats behaviour works but placed in a rollout I can get the result but as soon as I click back in my sme view the selected materials gets deleted

code I used :

rollout testRollout "CGS rollout"
   (
   	button btnRun "run"
   
   	fn sme_getSelectedNodes _return:#sme_nodes = 
   	 (
   		   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()
   			   names = for n = 1 to view.numsubs collect (view[n].reference.name) ; max undo
   			 if _return == #sme_mats then (for n in allMats where findItem names n.name == 0 collect n)
   			 else (for n = 1 to viewNode.GetNumNodes() where findItem names (smeNode = viewNode.GetNode n).name == 0 collect smeNode)
   		   )
   	 )
   	 
   	on btnRun pressed do 
   	(
   		res = sme_getSelectedNodes _return:#sme_mats
   		print res
   	)
   ) -- end rollout testRollout
   
   
   createDialog testRollout width:175 height:100
Page 2 / 3