I was checking out this thread about a way to simulate drag-and-droping materials outside of the Material Editor:
http://forums.cgsociety.org/showthread.php?f=98&t=685803&highlight=drag+drop
and in it PiXeL_MoNKeY suggested a way of doing it using the LoneRobot method since max stores materials as unique strings. In the end MarcoBrunetta came up with a different solution, but I was curious if what PiXeL_MoNKeY wrote can be done since his version would allow dropping into the material editor and not just objects in the scene.
My question is how do I find out this “unique string” for a material for example in a material library somewhere?
I tried just loading a Temp Material Library and getting its first material, but max gave an error saying that it couldn’t convert the material to a “type: System.Object”
try (destroyDialog ::DragDropOps) catch()
rollout DragDropOps "LoneRobot Drag Drop" width:136 height:150
(
dotNetControl btndragdrop "label" pos:[5,5] width:125 height:139
on DragDropOps open do
(
btndragdrop.allowdrop = true
btndragdrop.text = "Hooray! A Drag/Drop Enabled Label!!!
To drop a Texturemap, just pass the map path string in the dataobject instead of a max file path. This will also work if draging a map to the material editor"
btndragdrop.borderstyle = (dotNetClass "System.Windows.Forms.BorderStyle").fixedsingle
btndragdrop.backcolor = (dotnetclass "System.Drawing.Color").orangered
btndragdrop.forecolor = (dotnetclass "System.Drawing.Color").yellow
)
on btndragdrop mousemove sender args do
(
if (sender.clientrectangle.contains args.x args.y) then setSysCur #arrow
else setSysCur #move
)
on btndragdrop mouseup sender args do
(
if (sender.clientrectangle.contains args.x args.y) then (print "asd")
else
(
theIniFile = getdir #maxData + "3dsmax.ini"
theKeys = getIniSetting theIniFile "FileList"
-- filenameString = "D:\Object.max" -- max object
-- filenameString = "D:\Texture.jpg" -- texture
filenameString = "?????????" -- material
-- matLib = loadTempMaterialLibrary "D:\MatLib.mat"
-- filenameString = matLib[1]
dropfile = dotnetobject "System.String[]" 1
dropfile.setvalue filenameString 0
DataObj = dotnetobject "DataObject" ((dotnetclass "DataFormats").filedrop) dropfile
sender.dodragdrop Dataobj ((dotnetclass "DragDropEffects").Copy)
)
)
)
createdialog DragDropOps style:#(#style_toolwindow, #style_sysmenu)
