Hi everybody. Tell me:
how do I move several materials from Temporary Library to an open SME view and focus on them?
Move material from Temporary Library to an open SME
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 mat.name == "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
)
else
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.
no need to search for window handle
(SME.GetMainframe()).setfocus()
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
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
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