Move material from Temporary Library to an open SME


Hi everybody. Tell me:
how do I move several materials from Temporary Library to an open SME view and focus on them?


Try with this:

	function AddMaterialToSME mat = 
		if sme.isOpen() do
			view = sme.activeView
			view.CreateNode mat	
	tempMatsArr = loadTempMaterialLibrary @"C:\My_Temp_Mat_Library.mat"
	if tempMatsArr.count != 0 do
		for mat in tempMatsArr where == "My_Material" do
			AddMaterialToSME mat

    WM_COMMAND = 0x111
	ID = 0xA02C -- Layout All Button source ID
	function AddMaterialToSME mat view = 
		view.CreateNode mat [0,0]	

		hwnd = windows.getChildHWND 0 "Slate Material Editor"		
		windows.sendMessage hwnd[1] WM_COMMAND ID 0 
	local libraryPath = getOpenFileName caption:"Material Library File" types:("Material Library (*.mat)|*.mat")
	if libraryPath != undefined do
		tempMatsArr = (loadTempMaterialLibrary libraryPath)
		if tempMatsArr.count != 0 and (sme.isOpen()) then
			view = (sme.getview sme.activeView)	
			for mat in tempMatsArr do
				AddMaterialToSME mat view
			print ("ERROR: Could not load " + libraryPath + ".")

SME must be open.


Thanks! it works)
can I focus on them in SME?
they are sometimes created behind the field of view


Check the code. It is updated.
The method of arranging the created material was shown by Serejah or denisT(I don’t remember), so you have to thanks to them. :slight_smile:


no need to search for window handle

actionMan.executeAction 369891408 "40060" -- Lay Out All
sme actions

Table:SME id:369891408

Assign Material to Selection id:β€œ40500” category: SME
Delete Selected id:β€œ40058” category: SME
Select All id:β€œ40063” category: SME
Select None id:β€œ40064” category: SME
Select Invert id:β€œ40065” category: SME
Select Children id:β€œ40066” category: SME
Deselect Children id:β€œ40067” category: SME
Lay Out All id:β€œ40060” category: SME
Lay Out Children id:β€œ40076” category: SME
Show Grid id:β€œ40061” category: SME
Zoom Extents id:β€œ40070” category: SME
Zoom Extents Selected id:β€œ40071” category: SME
Pan to Selected id:β€œ40072” category: SME
Hide Unused Nodeslots id:β€œ40075” category: SME
Move Children id:β€œ40077” category: SME
Material/Map Browser id:β€œ40068” category: SME
Parameter Editor id:β€œ40069” category: SME
Select Tool id:β€œ55560” category: SME
Pan Tool id:β€œ55561” category: SME
Zoom Tool id:β€œ55562” category: SME
Zoom Region Tool id:β€œ55563” category: SME
Select Tree id:β€œ55564” category: SME
Navigator id:β€œ55565” category: SME
Rename id:β€œ55566” category: SME
Clear View id:β€œ55567” category: SME
Update Selected Previews id:β€œ55570” category: SME
Auto Update Selected Previews id:β€œ55571” category: SME
Propagate Materials to Instances id:β€œ55574” category: SME
Enable Global Rendering id:β€œ55572” category: SME
Open / Close Selected Nodes id:β€œ55573” category: SME
Clean MultiMaterial id:β€œ55575” category: SME
Instance Duplicate Map id:β€œ55576” category: SME
Render Map id:β€œ55577” category: SME
Select Objects By Material id:β€œ55578” category: SME
Highlight Assets in ATS Dialog id:β€œ55579” category: SME
Put Material to Scene id:β€œ55580” category: SME
Get from Selected id:β€œ55581” category: SME
Focus On Input id:β€œ27665” category: SME – these two are my custom ones
Connect Multiple Nodes id:β€œ4242” category: SME


Will this work on max2016?


and how to use it with this code? I’ve already seen it, but I haven’t figured out how to use it.
I understand: does he take the material from the object

if (mat = selection[1].material) != indefined do
	view = (sme.getview sme.activeView)
	AddMaterialToSME mat view

For selected object.


actionman.executeAction should work for any version

add all needed materials from the library then once call layout all command. that’s it

select materials that you just added and call Pan to Selected action


just how to highlight the materials when they were created?


mxs reference is your best friend if you’re going to write scripts
<void>SetSelectedNodes <maxObject by value array>refs
used like this

array_of_materials = ...
view = SME.GetView SME.ActiveView
view.SetSelectedNodes array_of_materials

as an alternative every sme node has .selected property which you can set to true

sme_node = view.createNode (falloff()) [10,10]
sme_node.Selected = true

As a non-destructive workflow I’d do it like this

  • Store previous sme selection
  • Deselect all view nodes
  • Put new materials/textures into active view
  • Layout all nodes in a view
  • Select newly created nodes
  • Pan to selected
  • Restore previous selection