[Closed] 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 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
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
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.