the easiest way is to copy and paste into the any of the files of the mxsagni project in the samples and recompile (as release) it and replace the mxsagni.dlx in stdplugins with the newly compiled version.
Klvnk. could you make a tutorial how to do this please? When I look to Useful mxs sdk extension functions I understand that for some people it is useful, but unfortunately not for me, because I don’t know how to use them
Yes please Klunk, that would be an awesome tutorial. I’d love to use that function.
almost all functions in the “useful maxscript extentions” thread are really-really useful.
thanks Klvnk, would it be possible to add “cleaan way” or if possible on the fly compile like in C# code ?
I’m sure it’s possible but I’m probably not the man for that sort of thing c# is not my bag !
Ya, thanks Denis, reckon I should ban myself from trying to think at weekends.
Opening the preview window seems to be a little buggy, especially if you already have some preview windows opened.
I thought perhaps using just one Material Slot and changing it could be useful too, for example if you have a scene with materials that are not currently opened in the Editor.
I haven’t tested if it really captures the material preview or if it works with different Renderers. In theory I believe it should work.
The code below does not use the DialogMonitorOPS. It is just some testing thing and so it is a little messy. Also it is missing the C# functions for capturing the screen.
The flashing Editor is annoying, but I think it could be hidden with a bit of C# or moved out of screen.
(
fn GrabPreviewThumbnail mHWND =
(
-- Nothing here, just print the material name
print (UIAccessor.GetWindowText mHWND)
)
fn GetMaterialEditorHWNDs mClosePreviews:true =
(
children = windows.getChildrenHWND 0
editorHWND = undefined
previewHWND = undefined
for j in children do
(
hwnd = j[1]
class = j[4]
if class == "#32770" do
(
DLL = UIAccessor.GetWindowDllFileName hwnd
DLL = filenamefromPath DLL
if DLL == "res1.dll" do
(
if (UIAccessor.GetChildWindows hwnd).count == 3 then
(
if mClosePreviews do UIAccessor.CloseDialog hwnd
previewHWND = hwnd
)else(
editorHWND = hwnd
)
)
)
)
return #(editorHWND, previewHWND)
)
fn BuildMaterialsPreviews mType =
(
case mType of
(
1: (materials = for j in scenematerials collect j)
2: (materials = for j in meditmaterials collect j)
default: return ()
)
materialEditor = MatEditor.mode
MatEditor.mode = #basic
MatEditor.Open()
GetMaterialEditorHWNDs mClosePreviews:true
medit.SetActiveMtlSlot 1 true
windows.processPostedMessages()
materialSlot1 = meditmaterials[1]
actionMan.executeAction 2 "40296"
HWNDs = GetMaterialEditorHWNDs mClosePreviews:false
previewHWND = HWNDs[2]
for j in materials do
(
meditmaterials[1] = j
windows.processPostedMessages()
-- Grab Image here
GrabPreviewThumbnail previewHWND
)
UIAccessor.CloseDialog previewHWND
meditmaterials[1] = materialSlot1
MatEditor.mode = materialEditor
)
BuildMaterialsPreviews 1
)
recent max versions have getWindowPos method. the preview window pops up on the top. so we can use .net screen grab methods instead of print HDC
so today with recent versions of max we can do everything without extra pre-compiled (or on-the-fly) .net assemblies
Yes, I thought of capturing the screen too, but what would happen if the user switches to another application in the process?
what is the user doing? grabbing material previews. why does he wish to switch to anything else?
the same way i can ask what would happen if a user plugs his computer off? the proofing a tool from pets and blondes is not a modern technique.
Very logic, very lineal… but…
Life is not so logic neither so lineal. Otherwise software development would be a piece of cake.