PDA

View Full Version : Material Lister Script


reForm
02-25-2006, 03:58 PM
------------------------------------------------------------------------------
/edit
Download the latest version of this script here :-
http://www.reformstudios.com/03-resources/MatLister/VRayMatList_0_42.ms
/edit
--------------------------------------------------------------------------------

I'm trying to write a material lister macroscript at the moment. Its my first serious venture into the world of maxscript.... so it may be beyond my skills.

Anyway, I've managed to rip out alot of code from the light lister script, and have got as far as getting the basic structure together. I've reached a bit of a brick wall trying to fix a bug that stops the labels from getting added to the rollout.

Can anyone have a look and see if they can see what the problem is?

Whats weird is that the lightlister script calls the function 'writeTitle'... when I do the same in my script it doesnt work... but adding () to the function call works.... but creates another problem when it attempts to add the labels/controllers.

Any help appreciated ! :)

---------------------------------------------------------------------------
--MATERIAL LISTER
--VRayMatList_0_5.ms--Beta 0.10
--Started 21.02.06
--Code By Patrick Macdonald
--mail@reformstudios.com
---------------------------------------------------------------------------
--SHORT DESCRIPTION:
--Listing of all scene materials with control over all material properties.
---------------------------------------------------------------------------
---------------------------------------------------------------------------
--Notes
--------
--0.3 Limited to VrayMtl class materials.

macroScript Material_List
enabledIn:#("max", "viz", "vizr") --pfb: 2003.12.12 added product switch
category:"Medit"
internalcategory:"Lights and Cameras"
ButtonText:"Material Lister..."
tooltip:"Material Lister..."
Icon:#("Lights",7)
-- SilentErrors:(Debug != True)
(

struct MatListerStruct (vrayMatRC, vrayMatList, MatInspectorSetup, \
CreateMatRollout, MatInspectorFloater, MatInspectorListRollout, \
materialsList, DeleCallback, MLUndoStr, DeleteCallback, \
count, lbcount, matIndex, totalMatCount, getMatProp, setMatProp, enableRefreshBtn, \
LineOffset, disableUIElements, UIControlList, enableUIElements, CreateMatRollout, \
yOffset, LineOffset )

global MLister, MListerYOffset
MLister = MatListerStruct()

-- Strings for localisation
MLister.MLUndoStr = "MaterialLister"

local dialogUp = false

-- End Strings

-- Position to help localisation

MListerYOffset = 0
MLister.yOffset = MListerYOffset
MLister.LineOffset = 0




------------------------------
-------- Globals -------------
------------------------------




------------------------------
----- useful functions -------
------------------------------
fn subtractFromArray myArray mySub =
(
tmpArray = #()
for i in myArray do append tmpArray i
for i in mySub do


(
itemNo = finditem tmpArray i
local newArray = #()
if itemNo != 0 do
(
for j in 1 to (itemNo-1) do append newArray tmpArray[j]
for j in (itemNo+1) to tmpArray.count do append newArray tmpArray[j]
tmpArray = newArray
)
)
tmpArray
)

fn copyArray array1 = for i in array1 collect i

fn SortNodeArrayByName myArray =
(
qsort myArray (fn myname v1 v2 = (if v1.name < v2.name then 0 else 1))
myArray
)

fn disableUIElements array1 = for i in array1 do execute ("maxLightsRollout." + i as string + ".enabled = false")
MLister.disableUIElements = disableUIElements

fn enableRefreshBtn materialobj =
(
if (MLister.GetMatProp materialObj #useGlobalShadowSettings) == true do
(
MLister.MatInspectorSetup.BtnReload.Checked = true
)
)
MLister.enableRefreshBtn = enableRefreshBtn

fn getMatProp obj prop =
(
if (isProperty obj prop) and not (isProperty obj #delegate) then
getProperty obj prop
else
if isProperty obj #delegate then
if isProperty obj.delegate prop then
getProperty obj.delegate prop
else undefined
else undefined
)
MLister.getMatProp = getMatProp

fn setMatProp obj prop val =
(
if (isProperty obj prop) and not (isProperty obj #delegate) then
setProperty obj prop val
else
if isProperty obj #delegate then
if isProperty obj.delegate prop then
setProperty obj.delegate prop val
else undefined
else undefined
)
MLister.setMatProp = setMatProp


------------------------------
----- Local variables --------
------------------------------

--topspace = 0
--spacer = 45
vrayMats = getclassinstances VrayMtl
MLister.vraymatlist = getclassinstances VrayMtl
--cnt = vrayMats.count


------------------------------
----- main function ---------
------------------------------



fn CreateMatRollout myCollection selection:false =
(
local CreateMatRollout

-------------------------------------------------------
--------------------- Class Definitions----------------
-------------------------------------------------------




-------------------------------------------------------
--------------------- Scene Parser --------------------
-------------------------------------------------------

SceneMats = MyCollection as array
SceneVrayMats = #()

-------------------------------------------------------
--------------------- Scene Parser --------------------
-------------------------------------------------------

tmpParser = #( \
tmpsceneVrayMats = copyArray sceneMats \
)

ListParser = #( \
MLister.vrayMatList = vraymats \
)


for i in 1 to tmpParser.count do
(
/* while tmpParser[i].count > 0 do
(

) */ --end While loop


) --end i loop


MLister.totalMatCount = MLister.vrayMatList

-------------------------------------------------------
---------- BuildControls and rollouts------------------
-------------------------------------------------------

MLister.totalMatCount = getclassinstances VrayMtl

MLister.vrayMatRC = rolloutCreator "vrayMatsRollout" "Materials"
MLister.vrayMatRC.begin()
MLister.vrayMatRC.addText "fn clearCheckButtons = for i in MLister.MatInspectorListRollout.controls do if classof i == checkButtonControl do if i.checked do i.checked = false\n"

MLister.count = 1
MLister.lbCount = 1
MLister.MatIndex = #()
MLister.UIControlList = #(#(), #())


-------------------------------------------------------
---------- Routine to add Column Headings -------------
-------------------------------------------------------



fn WriteTitle =
(

local lbName

fn lbName =
(
if MLister.lbcount == undefined do MLister.lbCount = 1
MLister.lbcount += 1
("LB" + MLister.lbCount as string) as name
) -- end function lbName

local labelOffset = -3
--MLister.vrayMatRC.addControl #label (lbname()) "Name" paramStr:(" align:#left offset:[28," + (-3 + MLister.yOffset + MLister.LineOffset) as string + "]")
--MLister.vrayMatRC.addControl #label (lbname()) "Dif." paramStr:(" align:#left offset:[182,"+ (-18 + LLister.yOffset) as string + "]")
--MLister.vrayMatRC.addControl #label (lbName()) "Reflect." paramStr:(" align:#left offset:[240,"+ (-18 + LLister.yOffset) as string + "]")

--------- Why do these not appear ? -----------------

MLister.vrayMatRC.addControl #checkButton (lbName()) "" paramStr:(" pos:[5,25] width:10 height:10")
MLister.vrayMatRC.addControl #label (lbName()) "Name:" paramStr:(" pos:[29,5] width:40 height:15")
MLister.vrayMatRC.addControl #label (lbName()) "Dif." paramStr:(" pos:[111,5] width:40 height:15")
MLister.vrayMatRC.addControl #label (lblName()) "Refl." paramStr:(" pos:[153,5] width:40 height:15")

MLister.vrayMatRC.addControl #editText (lbName()) "" paramStr:(" text:\"text\" pos:[16,22] width:80 height:15")

MLister.vrayMatRC.addControl #colorPicker (lbName()) "" paramStr:(" pos:[104,24] width:15 height:15 fieldWidth:15")


)
------------ end fn writetitle -----------------


-------------------------------------------------------
---------- routine to add material controls -----------
-------------------------------------------------------

fn CreateControls =

(
MLister.vrayMatRC.addControl #button #myButton "My Button"
append MLister.UIControlList[2][LLister.Count] (("LightSel" + MLister.count as string) as name)
MLister.UIControlList[1][MLister.count] = MLister.LightIndex[MLister.count][1]

)

if Mlister.vrayMatList.count > 0 do
(
writetitle
for x in 1 to Mlister.vrayMatList.count do
(
append MLister.MatIndex Mlister.vrayMatList[x]
createControls
MLister.count += 1
)
)

----------- end fn create controls --------------

local CanAddControls = true
local MatCountLimit = 150

-- Callback handlers
MLister.vrayMatRC.addHandler "vraymatsrollout" #'open' filter:off codeStr:("MLister.DeleteCallback = when MLister.UIControlList[1] deleted obj do" + \
"\n(\nlocal foundme = findItem MLister.UIControllist[1] obj\n" + \
"if foundMe > 0 do\n(\n" + \
"MLister.disableUIElements MLister.UIControlList[2][foundMe]\n)\n)")
MLister.vrayMatRC.addHandler "vrayMatsRollout" #'close' filter:off \
codeStr:"DeleteChangeHandler MLister.DeleteCallback"

MLister.vrayMatRC.end()

)-- end function CreateMatRollout

MLister.CreateMatRollout = CreateMatRollout

local matFilterTypes
matFilterTypes = #("All", "Vray", "VrayLightMtl", "VrayMtlWrapper", "Standard", "Composite", "MultiMaterial")

------- MAT INSPECTOR SETUP ------------
MLister.MatInspectorSetup =
(
local MatInspectorSetup
rollout MatInspectorSetup "Configuration" -- Localize
(
label lab1 "Filter:" pos:[5,0]
dropdownlist matFilter items:matFilterTypes width:80 pos:[0,13]




on matInspectorSetup close do
(
callbacks.removeScripts id:#MListerRollout

dialogUp = false
updateToolbarButtons()

)

on MatInspectorSetup open do
(
try(removerollout MLister.MatInspectorListRollout MLister.MatInspectorFloater) catch()

-------- MAT INSPECTOR LIST ROLLOUT

MLister.MatInspectorListRollout = MLister.CreateMatRollout (vrayMats as array)
if MLister.MatInspectorListRollout != undefined do
addRollout MLister.MatInspectorListRollout MLister.MatInspectorFloater
MLister.vrayMatRC = undefined
-- Callbacks to remove Floater
callBacks.AddScript #systemPreReset "CloseRolloutFloater MLister.MatInspectorFloater" id:#MListerRollout -- do not localize
callBacks.AddScript #systemPreNew "CloseRolloutFloater MLister.MatInspectorFloater" id:#MListerRollout -- do not localize
callBacks.AddScript #filePreOpen "CloseRolloutFloater MLister.MatInspectorFloater" id:#MListerRollout -- do not localize
dialogUp = true
updateToolbarButtons()
)
) --end of matinspector rollout

) -- end of mat inspector setup

on execute do
(
local dialogPos, dialogSize

dialogPos = [200,300]
dialogSize = [800,300]

try(closeRolloutFloater MLister.MatInspectorFloater) catch()
MLister.MatInspectorFloater = newRolloutFloater "Material Lister" 500 500 100 100

addRollout MLister.MatInspectorSetup MLister.MatInspectorFloater
dialogUp = true
)

on closeDialogs do
(
try(closeRolloutFloater MLister.MatInspectorFloater) catch( print "error in Material Lister" )
dialogUp = False
)
on isChecked return
(
dialogUp
)

)--end macroscript

Zbuffer
02-25-2006, 06:58 PM
When a function is called with no arguments you must write the ()

example:
-- fn with no arguments definition:
fn Myprint1=(print "something")
-- fn call:
MyPrint1()
-- fn with arguments definition
fn MyPrint2 str = (print str)
-- fn call:
Myprint2 "Something" -- no ()

so you should write :
writeTitle()
also there is a typo :(lblName()) should be (lbName())

for the rest I leave it up to you !

reForm
02-25-2006, 08:39 PM
thanks dude. Ah... jesus... that spello has been messing my up for ages! Amazing what a fresh pair of eyes can spot. Thanks!

As for the functions. I thought you only got away without () if you were returning values...
I'll need to pass some values to the function anyway, so I'll add them in and see if it sorts it out.

reForm
02-26-2006, 02:27 PM
At last, progress is being made.... the rollout seems to be working ok now, and I've got the diffuse channel link working. Now to get all the properties into the interface and linked up.

I was wondering about the best way to filter which parameters are visible. If anyone has any suggestion as to how the parameters are displayed, please let me know. (ie mode-1 would be the standard colours and spinners, mode-2 would be the map channels)

One other quick question. In the Light lister macro, calls to light parameters are done using :-
LLister.LightIndex[LLister.count][1].property

but for some reason this doesn't work with the MLister variables I have. What is the [1] refering to? I have adjusted the code to MLister.MatIndex[MLister.count].name which seems to work... but perhaps this will lead to problems further down the line (maybe when animating parameters? )

Thanks again for any help!

Latest code:-

---------------------------------------------------------------------------
--MATERIAL LISTER
--VRayMatList_0_5.ms--Beta 0.12
--Started 21.02.06
--Code By Patrick Macdonald
--mail@reformstudios.com
---------------------------------------------------------------------------
--SHORT DESCRIPTION:
--Listing of all scene materials with control over all material properties.
---------------------------------------------------------------------------
---------------------------------------------------------------------------
--Notes
--------
--0.3 Limited to VrayMtl class materials.

macroScript Material_List
enabledIn:#("max", "viz", "vizr") --pfb: 2003.12.12 added product switch
category:"Medit"
internalcategory:"Lights and Cameras"
ButtonText:"Material Lister..."
tooltip:"Material Lister..."
Icon:#("Lights",7)
-- SilentErrors:(Debug != True)
(
clearListener()
struct MatListerStruct (vrayMatRC, vrayMatList, MatInspectorSetup, \
CreateMatRollout, MatInspectorFloater, MatInspectorListRollout, \
materialsList, DeleCallback, MLUndoStr, DeleteCallback, \
count, lbCount, matIndex, totalMatCount, getMatProp, setMatProp, enableRefreshBtn, \
LineOffset, disableUIElements, UIControlList, enableUIElements, \
yOffset, LineOffset )

global MLister, MListerYOffset
MLister = MatListerStruct()

-- Strings for localisation
MLister.MLUndoStr = "MaterialLister"

local dialogUp = false

-- End Strings

-- Position to help localisation

MListerYOffset = 0
MLister.yOffset = MListerYOffset
MLister.LineOffset = 0




------------------------------
-------- Globals -------------
------------------------------




------------------------------
----- useful functions -------
------------------------------
fn subtractFromArray myArray mySub =
(
tmpArray = #()
for i in myArray do append tmpArray i
for i in mySub do


(
itemNo = finditem tmpArray i
local newArray = #()
if itemNo != 0 do
(
for j in 1 to (itemNo-1) do append newArray tmpArray[j]
for j in (itemNo+1) to tmpArray.count do append newArray tmpArray[j]
tmpArray = newArray
)
)
tmpArray
)

fn copyArray array1 = for i in array1 collect i

fn SortNodeArrayByName myArray =
(
qsort myArray (fn myname v1 v2 = (if v1.name < v2.name then 0 else 1))
myArray
)

fn disableUIElements array1 = for i in array1 do execute ("maxLightsRollout." + i as string + ".enabled = false")
MLister.disableUIElements = disableUIElements

fn enableRefreshBtn materialobj =
(
if (MLister.GetMatProp materialObj #useGlobalShadowSettings) == true do
(
MLister.MatInspectorSetup.BtnReload.Checked = true
)
)
MLister.enableRefreshBtn = enableRefreshBtn

fn getMatProp obj prop =
(
if (isProperty obj prop) and not (isProperty obj #delegate) then
getProperty obj prop
else
if isProperty obj #delegate then
if isProperty obj.delegate prop then
getProperty obj.delegate prop
else undefined
else undefined
)
MLister.getMatProp = getMatProp

fn setMatProp obj prop val =
(
if (isProperty obj prop) and not (isProperty obj #delegate) then
setProperty obj prop val
else
if isProperty obj #delegate then
if isProperty obj.delegate prop then
setProperty obj.delegate prop val
else undefined
else undefined
)
MLister.setMatProp = setMatProp


------------------------------
----- Local variables --------
------------------------------

--topspace = 0
--spacer = 45
vrayMats = getclassinstances VrayMtl
MLister.vraymatlist = getclassinstances VrayMtl
--cnt = vrayMats.count


------------------------------
----- main function ---------
------------------------------

local CreateMatRollout

fn CreateMatRollout myCollection =
(


-------------------------------------------------------
--------------------- Class Definitions----------------
-------------------------------------------------------




-------------------------------------------------------
--------------------- Scene Parser --------------------
-------------------------------------------------------

SceneMats = MyCollection as array
SceneVrayMats = #()

-------------------------------------------------------
--------------------- Scene Parser --------------------
-------------------------------------------------------

tmpParser = #( \
tmpsceneVrayMats = copyArray sceneMats \
)

ListParser = #( \
MLister.vrayMatList = vraymats \
)


for i in 1 to tmpParser.count do
(

) --end i loop


MLister.totalMatCount = MLister.vrayMatList

-------------------------------------------------------
---------- BuildControls and rollouts------------------
-------------------------------------------------------

MLister.totalMatCount = getclassinstances VrayMtl

MLister.vrayMatRC = rolloutCreator "vrayMatsRollout" "Materials"
MLister.vrayMatRC.begin()
-- MLister.vrayMatRC.addText "fn clearCheckButtons = for i in MLister.MatInspectorListRollout.controls do if classof i == checkButtonControl do if i.checked do i.checked = false\n"

MLister.count = 1
MLister.lbCount = 1
MLister.MatIndex = #()
MLister.UIControlList = #(#(), #())


-------------------------------------------------------
---------- Routine to add Column Headings -------------
-------------------------------------------------------



fn WriteTitle =
(

local lbName

fn lbName =
(
if MLister.lbCount == undefined do MLister.lbCount = 1
MLister.lbCount += 1
("LB" + MLister.lbCount as string) as name
) -- end function lbName

local labelOffset = -3
--MLister.vrayMatRC.addControl #label (lbname()) "Name" paramStr:(" align:#left offset:[28," + (-3 + MLister.yOffset + MLister.LineOffset) as string + "]")
--MLister.vrayMatRC.addControl #label (lbname()) "Dif." paramStr:(" align:#left offset:[182,"+ (-18 + LLister.yOffset) as string + "]")
--MLister.vrayMatRC.addControl #label (lbName()) "Reflect." paramStr:(" align:#left offset:[240,"+ (-18 + LLister.yOffset) as string + "]")

--------- Why do these not appear ? -----------------

MLister.vrayMatRC.addControl #label (lbName()) "Name:" paramStr:(" pos:[29," + (0 + MLister.yOffset + MLister.LineOffset) as string + "] width:40 height:15")
MLister.vrayMatRC.addControl #label (lbName()) "Dif." paramStr:(" pos:[111," + (0 + MLister.yOffset + MLister.LineOffset) as string + "] width:40 height:15")
MLister.vrayMatRC.addControl #label (lbName()) "Refl." paramStr:(" pos:[153," + (0 + MLister.yOffset + MLister.LineOffset) as string + "] width:40 height:15")


)
------------ end fn writetitle -----------------


-------------------------------------------------------
---------- routine to add material controls -----------
-------------------------------------------------------

fn CreateControls =

(
local lbName

fn lbName =
(
if MLister.lbCount == undefined do MLister.lbCount = 1
MLister.lbCount += 1
("LB" + MLister.lbCount as string) as name
) -- end function lbName

local isMatSelected = false
--for i in Mlister.MatIndex[MLister.count] where (not isMatSelected) do isMatSelected = i.isSelected

MLister.UIControlList[1][MLister.count] = MLister.MatIndex[MLister.count][1]
MLister.UIControlList[2][MLister.count] = #()

MLister.vrayMatRC.addControl #checkButton (("MatSel" + MLister.count as string) as name) "" \
paramStr:("checked:" +(isMatSelected as string) + " offset:[-5,"+ (-2+ MLister.yOffset + MLister.LineOffset) as string + "] align:#left" + \
" width:10 height:20 ")

MLister.vrayMatRC.addControl #editText (("MatName" + MLister.count as string) as name) "" \
paramStr:(" text:\"" + MLister.matindex[MLister.count].name as string + "\" offset:[5," \
+ (-25 + MLister.yOffset + MLister.LineOffset) as string + "] align:#left width:90 height:20 ")

MLister.vrayMatRC.addControl #colorPicker (("MatDiffCol" + MLister.count as string) as name) "" \
paramStr:(" offset:[95," + (-23 + MLister.yOffset + MLister.LineOffset) as string + \
"] color:" + (MLister.getMatProp MLister.MatIndex[MLister.count] #diffuse) as string + \
" width:15 height:15 fieldWidth:15")
MLister.vrayMatRC.addHandler (("MatDiffCol" + MLister.count as string) as name) #'changed val' filter:on \
codeStr:("MLister.setMatProp MLister.MatIndex[" + MLister.count as string + "] #diffuse val")


--MLister.vrayMatRC.addControl #button #myButton "My Button"

append MLister.UIControlList[2][MLister.Count] (("MatSel" + MLister.count as string) as name)
MLister.UIControlList[1][MLister.count] = MLister.MatIndex[MLister.count][1]

)

if Mlister.vrayMatList.count > 0 do
(
writetitle ()

for x in 1 to Mlister.vrayMatList.count do
(
append MLister.MatIndex Mlister.vrayMatList[x]
createControls ()
MLister.count += 1
)
)

----------- end fn create controls --------------

local CanAddControls = true
local MatCountLimit = 150

-- Callback handlers
MLister.vrayMatRC.addHandler "vraymatsrollout" #'open' filter:off codeStr:("MLister.DeleteCallback = when MLister.UIControlList[1] deleted obj do" + \
"\n(\nlocal foundme = findItem MLister.UIControllist[1] obj\n" + \
"if foundMe > 0 do\n(\n" + \
"MLister.disableUIElements MLister.UIControlList[2][foundMe]\n)\n)")
MLister.vrayMatRC.addHandler "vrayMatsRollout" #'close' filter:off \
codeStr:"DeleteChangeHandler MLister.DeleteCallback"

MLister.vrayMatRC.end()

)-- end function CreateMatRollout

MLister.CreateMatRollout = CreateMatRollout
local matFilterTypes
matFilterTypes = #("All", "Vray", "VrayLightMtl", "VrayMtlWrapper", "Standard", "Composite", "MultiMaterial")

------- MAT INSPECTOR SETUP ------------
MLister.MatInspectorSetup =
(
local MatInspectorSetup
rollout MatInspectorSetup "Configuration" -- Localize
(

label lab1 "Filter:" pos:[5,0]
dropdownlist matFilter items:matFilterTypes width:80 pos:[0,13]

on btnReload changed state do
(
roloutSelector.changed rolloutSelector.state
btnReload.checked = false
)

on matInspectorSetup close do
(
callbacks.removeScripts id:#MListerRollout

dialogUp = false
updateToolbarButtons()

)

on MatInspectorSetup open do
(
local laststate = 5
if laststate < 4 do rolloutSelector.changed = laststate

try (removerollout MLister.MatInspectorListRollout MLister.MatInspectorFloater) catch()
MLister.MatInspectorListRollout = MLister.CreateMatRollout (vrayMats as array)
if MLister.MatInspectorListRollout != undefined do
addRollout MLister.MatInspectorListRollout MLister.MatInspectorFloater

MLister.vrayMatRC = undefined

--MLister.vrayMatRC = undefined
--Callbacks to remove Floater
--callBacks.AddScript #systemPreReset "CloseRolloutFloater MLister.MatInspectorFloater" id:#MListerRollout -- do not localize
--callBacks.AddScript #systemPreNew "CloseRolloutFloater MLister.MatInspectorFloater" id:#MListerRollout -- do not localize
--callBacks.AddScript #filePreOpen "CloseRolloutFloater MLister.MatInspectorFloater" id:#MListerRollout -- do not localize
dialogUp = true
--updateToolbarButtons()
)


) --end of matinspector rollout

) -- end of mat inspector setup

on execute do
(
local dialogPos, dialogSize

dialogPos = [200,300]
dialogSize = [800,300]

try(closeRolloutFloater MLister.MatInspectorFloater) catch()
MLister.MatInspectorFloater = newRolloutFloater "Material Lister" 500 500 100 100

addRollout MLister.MatInspectorSetup MLister.MatInspectorFloater
dialogUp = true
)

on closeDialogs do
(
try(closeRolloutFloater MLister.MatInspectorFloater) catch( print "error in Material Lister" )
dialogUp = False
)
on isChecked return
(
dialogUp
)

)--end macroscript

reForm
02-26-2006, 04:54 PM
another update....

Controls to make the maps visible added.

---------------------------------------------------------------------------
--MATERIAL LISTER
--VRayMatList_0_5.ms--Beta 0.13
--Started 21.02.06
--Code By Patrick Macdonald
--mail@reformstudios.com
---------------------------------------------------------------------------
--SHORT DESCRIPTION:
--Listing of all scene materials with control over all material properties.
---------------------------------------------------------------------------
---------------------------------------------------------------------------
--Notes
--------
--0.3 Limited to VrayMtl class materials.

macroScript Material_List
enabledIn:#("max", "viz", "vizr") --pfb: 2003.12.12 added product switch
category:"Medit"
internalcategory:"Lights and Cameras"
ButtonText:"Material Lister..."
tooltip:"Material Lister..."
Icon:#("Lights",7)
-- SilentErrors:(Debug != True)
(
clearListener()
struct MatListerStruct (vrayMatRC, vrayMatList, MatInspectorSetup, \
CreateMatRollout, MatInspectorFloater, MatInspectorListRollout, \
materialsList, DeleCallback, MLUndoStr, DeleteCallback, \
count, lbCount, matIndex, totalMatCount, getMatProp, setMatProp, enableRefreshBtn, \
LineOffset, disableUIElements, UIControlList, enableUIElements, \
yOffset, LineOffset, showTexMap, showSpin )

global MLister, MListerYOffset
MLister = MatListerStruct()

-- Strings for localisation
MLister.MLUndoStr = "MaterialLister"

local dialogUp = false

-- End Strings

-- Position to help localisation

MListerYOffset = 2
MLister.yOffset = MListerYOffset
MLister.LineOffset = 0
MLister.showTexMap = 0




------------------------------
-------- Globals -------------
------------------------------




------------------------------
----- useful functions -------
------------------------------
fn subtractFromArray myArray mySub =
(
tmpArray = #()
for i in myArray do append tmpArray i
for i in mySub do


(
itemNo = finditem tmpArray i
local newArray = #()
if itemNo != 0 do
(
for j in 1 to (itemNo-1) do append newArray tmpArray[j]
for j in (itemNo+1) to tmpArray.count do append newArray tmpArray[j]
tmpArray = newArray
)
)
tmpArray
)

fn copyArray array1 = for i in array1 collect i

fn SortNodeArrayByName myArray =
(
qsort myArray (fn myname v1 v2 = (if v1.name < v2.name then 0 else 1))
myArray
)

fn disableUIElements array1 = for i in array1 do execute ("maxLightsRollout." + i as string + ".enabled = false")
MLister.disableUIElements = disableUIElements

fn enableRefreshBtn materialobj =
(
if (MLister.GetMatProp materialObj #useGlobalShadowSettings) == true do
(
MLister.MatInspectorSetup.BtnReload.Checked = true
)
)
MLister.enableRefreshBtn = enableRefreshBtn

fn getMatProp obj prop =
(
if (isProperty obj prop) and not (isProperty obj #delegate) then
getProperty obj prop
else
if isProperty obj #delegate then
if isProperty obj.delegate prop then
getProperty obj.delegate prop
else undefined
else undefined
)
MLister.getMatProp = getMatProp

fn setMatProp obj prop val =
(
if (isProperty obj prop) and not (isProperty obj #delegate) then
setProperty obj prop val
else
if isProperty obj #delegate then
if isProperty obj.delegate prop then
setProperty obj.delegate prop val
else undefined
else undefined
)
MLister.setMatProp = setMatProp


------------------------------
----- Local variables --------
------------------------------

--topspace = 0
--spacer = 45
vrayMats = getclassinstances VrayMtl
MLister.vraymatlist = getclassinstances VrayMtl
--cnt = vrayMats.count


------------------------------
----- main function ---------
------------------------------

local CreateMatRollout

fn CreateMatRollout myCollection =
(


-------------------------------------------------------
--------------------- Class Definitions----------------
-------------------------------------------------------




-------------------------------------------------------
--------------------- Scene Parser --------------------
-------------------------------------------------------

SceneMats = MyCollection as array
SceneVrayMats = #()

-------------------------------------------------------
--------------------- Scene Parser --------------------
-------------------------------------------------------

tmpParser = #( \
tmpsceneVrayMats = copyArray sceneMats \
)

ListParser = #( \
MLister.vrayMatList = vraymats \
)


for i in 1 to tmpParser.count do
(

) --end i loop


MLister.totalMatCount = MLister.vrayMatList

-------------------------------------------------------
---------- BuildControls and rollouts------------------
-------------------------------------------------------

MLister.totalMatCount = getclassinstances VrayMtl

MLister.vrayMatRC = rolloutCreator "vrayMatsRollout" "Materials"
MLister.vrayMatRC.begin()
-- MLister.vrayMatRC.addText "fn clearCheckButtons = for i in MLister.MatInspectorListRollout.controls do if classof i == checkButtonControl do if i.checked do i.checked = false\n"

MLister.count = 1
MLister.lbCount = 1
MLister.MatIndex = #()
MLister.UIControlList = #(#(), #())


-------------------------------------------------------
---------- Routine to add Column Headings -------------
-------------------------------------------------------



fn WriteTitle =
(

local lbName

fn lbName =
(
if MLister.lbCount == undefined do MLister.lbCount = 1
MLister.lbCount += 1
("LB" + MLister.lbCount as string) as name
) -- end function lbName

local labelOffset = -3
--MLister.vrayMatRC.addControl #label (lbname()) "Name" paramStr:(" align:#left offset:[28," + (-3 + MLister.yOffset + MLister.LineOffset) as string + "]")
--MLister.vrayMatRC.addControl #label (lbname()) "Dif." paramStr:(" align:#left offset:[182,"+ (-18 + LLister.yOffset) as string + "]")
--MLister.vrayMatRC.addControl #label (lbName()) "Reflect." paramStr:(" align:#left offset:[240,"+ (-18 + LLister.yOffset) as string + "]")

--------- Why do these not appear ? -----------------

MLister.vrayMatRC.addControl #label (lbName()) "Name:" paramStr:(" pos:[29," + (0 + MLister.yOffset + MLister.LineOffset) as string + "] width:40 height:15")
MLister.vrayMatRC.addControl #label (lbName()) "Dif." paramStr:(" pos:[111," + (0 + MLister.yOffset + MLister.LineOffset) as string + "] width:40 height:15")
MLister.vrayMatRC.addControl #label (lbName()) "Refl." paramStr:(" pos:[143," + (0 + MLister.yOffset + MLister.LineOffset) as string + "] width:40 height:15")


)
------------ end fn writetitle -----------------


-------------------------------------------------------
---------- routine to add material controls -----------
-------------------------------------------------------

fn CreateControls showTexMap:false =

(
local lbName

fn lbName =
(
if MLister.lbCount == undefined do MLister.lbCount = 1
MLister.lbCount += 1
("LB" + MLister.lbCount as string) as name
) -- end function lbName

local isUsingEdittextOffset = 0, editTextSize = 75
local isMatSelected = false
--for i in Mlister.MatIndex[MLister.count] where (not isMatSelected) do isMatSelected = i.isSelected

MLister.UIControlList[1][MLister.count] = MLister.MatIndex[MLister.count][1]
MLister.UIControlList[2][MLister.count] = #()


-- Select Material Toggle
MLister.vrayMatRC.addControl #checkButton (("MatSel" + MLister.count as string) as name) "" \
paramStr:("checked:" +(isMatSelected as string) + " offset:[-5,"+ (-2+ MLister.yOffset + MLister.LineOffset) as string + "] align:#left" + \
" width:10 height:20 ")


-- Material Name Text field
MLister.vrayMatRC.addControl #editText (("MatName" + MLister.count as string) as name) "" \
paramStr:(" text:\"" + MLister.matindex[MLister.count].name + "\" offset:[5," \
+ (-25 + MLister.yOffset + MLister.LineOffset) as string + "] align:#left width:90 height:16 ")
MLister.vrayMatRC.addHandler (("MatName" + MLister.count as string) as name) #'changed txt' filter:on \
codeStr:("MLister.MatIndex[" + MLister.count as string + "].name = txt")



-- Diffuse Colour Picker
MLister.vrayMatRC.addControl #colorPicker (("MatDiffCol" + MLister.count as string) as name) "" \
paramStr:(" offset:[95," + (-22 + MLister.yOffset + MLister.LineOffset) as string + \
"] color:" + (MLister.getMatProp MLister.MatIndex[MLister.count] #diffuse) as string + \
" width:15 height:15 fieldWidth:15")
MLister.vrayMatRC.addHandler (("MatDiffCol" + MLister.count as string) as name) #'changed val' filter:on \
codeStr:("MLister.setMatProp MLister.MatIndex[" + MLister.count as string + "] #diffuse val")

-- Diffuse Colour Material
if showTexMap then
(

MLister.vrayMatRC.addControl #mapbutton (("MatDiffMap" + MLister.count as string) as name) ((MLister.MatIndex[MLister.count].texmap_diffuse) as string) \
paramStr:("tooltip:\"Select Diffuse Map\" align:#left height:15 width:80 offset:[112," + (-22 + MLister.yOffset + MLister.LineOffset) as string + \
"]")
MLister.vrayMatRC.addHandler (("MatDiffMap" + MLister.count as string) as name) #'picked texmap' filter:on \
codeStr:("MLister.MatIndex[" + MLister.count as string + "].texmap_diffuse texmap\n" + ("MatDiffMap" + MLister.count as string) + ".text = classof texmap as string ")
)
else
(
MLister.vrayMatRC.addControl #mapbutton (("MatDiffMap" + MLister.count as string) as name) "" \
paramStr:("tooltip:\"Select Diffuse Map\" align:#left height:15 width:10 offset:[112," + (-22 + MLister.yOffset + MLister.LineOffset) as string + \
"]")
MLister.vrayMatRC.addHandler (("MatDiffMap" + MLister.count as string) as name) #'picked texmap' filter:on \
codeStr:("MLister.MatIndex[" + MLister.count as string + "].texmap_diffuse texmap\n" + ("MatDiffMap" + MLister.count as string) + ".text = classof texmap as string ")

)


-- Reflection Colour Picker
MLister.vrayMatRC.addControl #colorPicker (("MatReflCol" + MLister.count as string) as name) "" \
paramStr:(" offset:[" + (125+(80*MLister.showtexmap)) as string + "," + (-22 + MLister.yOffset + MLister.LineOffset) as string + \
"] color:" + (MLister.getMatProp MLister.MatIndex[MLister.count] #reflection) as string + \
" width:15 height:15 fieldWidth:15")
MLister.vrayMatRC.addHandler (("MatReflCol" + MLister.count as string) as name) #'changed val' filter:on \
codeStr:("MLister.setMatProp MLister.MatIndex[" + MLister.count as string + "] #reflection val")

-- Reflection Colour Material
if showTexMap then
(

MLister.vrayMatRC.addControl #mapbutton (("MatReflMap" + MLister.count as string) as name) ((MLister.MatIndex[MLister.count].texmap_reflection) as string) \
paramStr:("tooltip:\"Select Reflection Map\" align:#left height:15 width:80 offset:[" + (142+(80*MLister.showtexmap)) as string + "," + (-22 + MLister.yOffset + MLister.LineOffset) as string + \
"]")
MLister.vrayMatRC.addHandler (("MatReflMap" + MLister.count as string) as name) #'picked texmap' filter:on \
codeStr:("MLister.MatIndex[" + MLister.count as string + "].texmap_reflection texmap\n" + ("MatReflMap" + MLister.count as string) + ".text = classof texmap as string ")
)
else
(
MLister.vrayMatRC.addControl #mapbutton (("MatReflMap" + MLister.count as string) as name) "" \
paramStr:("tooltip:\"Select Reflection Map\" align:#left height:15 width:10 offset:[142," + (-22 + MLister.yOffset + MLister.LineOffset) as string + \
"]")
MLister.vrayMatRC.addHandler (("MatReflMap" + MLister.count as string) as name) #'picked texmap' filter:on \
codeStr:("MLister.MatIndex[" + MLister.count as string + "].texmap_reflection texmap\n" + ("MatReflMap" + MLister.count as string) + ".text = classof texmap as string ")

)

append MLister.UIControlList[2][MLister.Count] (("MatSel" + MLister.count as string) as name)
MLister.UIControlList[1][MLister.count] = MLister.MatIndex[MLister.count][1]

)

if Mlister.vrayMatList.count > 0 do
(
writetitle ()

for x in 1 to Mlister.vrayMatList.count do
(
append MLister.MatIndex Mlister.vrayMatList[x]
if MLister.showTexMap == 1 then createControls showTexMap:true
else createControls showTexMap:false

MLister.count += 1
)
)

----------- end fn create controls --------------

local CanAddControls = true
local MatCountLimit = 150

-- Callback handlers
MLister.vrayMatRC.addHandler "vraymatsrollout" #'open' filter:off codeStr:("MLister.DeleteCallback = when MLister.UIControlList[1] deleted obj do" + \
"\n(\nlocal foundme = findItem MLister.UIControllist[1] obj\n" + \
"if foundMe > 0 do\n(\n" + \
"MLister.disableUIElements MLister.UIControlList[2][foundMe]\n)\n)")
MLister.vrayMatRC.addHandler "vrayMatsRollout" #'close' filter:off \
codeStr:"DeleteChangeHandler MLister.DeleteCallback"

MLister.vrayMatRC.end()

)-- end function CreateMatRollout

MLister.CreateMatRollout = CreateMatRollout
local matFilterTypes
matFilterTypes = #("All", "Vray", "VrayLightMtl", "VrayMtlWrapper", "Standard", "Composite", "MultiMaterial")

------- MAT INSPECTOR SETUP ------------
MLister.MatInspectorSetup =
(
local MatInspectorSetup
rollout MatInspectorSetup "Configuration" -- Localize
(

label lab1 "Filter:" pos:[5,0]
dropdownlist matFilter items:matFilterTypes width:80 pos:[0,13]
label lab2 "View parameters"
checkbutton checkShowMaps "Maps" offset:[-10,0] align:#left
checkbutton checkShowspin "Spinners" offset:[40,-25] align:#left

on checkShowMaps changed state do
(
if state == on
then MLister.showTexMap = 1
else MLister.showTexMap = 0

try (removerollout MLister.MatInspectorListRollout MLister.MatInspectorFloater) catch()
MLister.MatInspectorListRollout = MLister.CreateMatRollout (vrayMats as array)
if MLister.MatInspectorListRollout != undefined do
addRollout MLister.MatInspectorListRollout MLister.MatInspectorFloater

MLister.vrayMatRC = undefined

)

on checkShowSpin changed state do
(
if state == on
then MLister.showSpin = 1
else MLister.showSpin = 0

try (removerollout MLister.MatInspectorListRollout MLister.MatInspectorFloater) catch()
MLister.MatInspectorListRollout = MLister.CreateMatRollout (vrayMats as array)
if MLister.MatInspectorListRollout != undefined do
addRollout MLister.MatInspectorListRollout MLister.MatInspectorFloater

MLister.vrayMatRC = undefined

)


on matInspectorSetup close do
(
callbacks.removeScripts id:#MListerRollout

dialogUp = false
updateToolbarButtons()

)

on MatInspectorSetup open do
(
local laststate = 5
if laststate < 4 do rolloutSelector.changed = laststate

try (removerollout MLister.MatInspectorListRollout MLister.MatInspectorFloater) catch()
MLister.MatInspectorListRollout = MLister.CreateMatRollout (vrayMats as array)
if MLister.MatInspectorListRollout != undefined do
addRollout MLister.MatInspectorListRollout MLister.MatInspectorFloater

MLister.vrayMatRC = undefined

--MLister.vrayMatRC = undefined
--Callbacks to remove Floater
--callBacks.AddScript #systemPreReset "CloseRolloutFloater MLister.MatInspectorFloater" id:#MListerRollout -- do not localize
--callBacks.AddScript #systemPreNew "CloseRolloutFloater MLister.MatInspectorFloater" id:#MListerRollout -- do not localize
--callBacks.AddScript #filePreOpen "CloseRolloutFloater MLister.MatInspectorFloater" id:#MListerRollout -- do not localize
dialogUp = true
--updateToolbarButtons()
)


) --end of matinspector rollout

) -- end of mat inspector setup

on execute do
(
local dialogPos, dialogSize

dialogPos = [200,300]
dialogSize = [800,300]

try(closeRolloutFloater MLister.MatInspectorFloater) catch()
MLister.MatInspectorFloater = newRolloutFloater "Material Lister" 500 500 100 100

addRollout MLister.MatInspectorSetup MLister.MatInspectorFloater
dialogUp = true
)

on closeDialogs do
(
try(closeRolloutFloater MLister.MatInspectorFloater) catch( print "error in Material Lister" )
dialogUp = False
)
on isChecked return
(
dialogUp
)

)--end macroscript

reForm
02-27-2006, 12:57 PM
Ok....I have a small question for you maxscript gurus. How do I get my filter function to successfuly select objects with the currently selected material?

Here's what I have so far.

fn objFilter ob =
(
if (classof ob == GeometryClass) do
(
if (ob.material.name != undefined) do (ob.material.name == MLister.matIndex[MLister.count].name)
)
)


The interface for the material lister is taking shape...
http://www.reformstudios.com/03-resources/MatLister/MatLister_Interface00.jpg

And the full script can be downloaded here.

http://www.reformstudios.com/03-resources/MatLister/VRayMatList_0_15.ms

reForm
03-01-2006, 05:37 PM
Another update.

I've got the filters working now, so you can pick and choose which material types to list. (although I have't implimented the display of any materials other than vray mats).

I've added buttons beneath each material:

S = Select objects with this material applied (not working... any help appreciated)

A = Apply material to selected objects (not implimented)

E = Edit material in material editor in selected slot.

and for the map slots...

V = View map in viewports.

E = Edit map in material editor in selected slot.


This already feels quite nice to use, even with such limited functionality.

So... no-one has any suggestions ? :roll:


Here's the latest interface:

http://www.reformstudios.com/03-resources/MatLister/MatLister_Interface01.jpg

reForm
03-02-2006, 01:37 AM
I have another slight problem I hope someone can help me with. I have a button to switch off all materials in the viewport of the current material.



MLister.vrayMatRC.addHandler (("ViewMatOff" + MLister.count as string) as name) #'pressed' codeStr:("mat = MLister.vraymatlist[" + MLister.count as string + "] \n names = getpropnames mat \n for i in names do (\n if superclassof mat." + i as string + " == texturemap do showtexturemap mat mat." + i as string + " false)")


which roughly translates as:-

on pressed do
( mat = MLister.vraymatlist[1]
names = getpropnames mat
for i in names do
(
if superclassof mat.i == texturemap do showTextureMap mat mat.i false
)
)

which should.... I think.... make sure that no materials have their visibility switched on in the viewport.....

Unfortunately, it doesn't work.
They key code is "if superclassof mat.texmap_diffuse == texturemap do showtexturemap mat mat.texmap_diffuse false" ... which works when I enter it into the listener.... but for some reason, it doesn't work when in the handler.

Can anyone help me out here?

:sad:

reForm
03-08-2006, 10:26 AM
Ok... another update.

I'm looking at how best to control the filtration of information. I think I need to provide two options,

Simple :
Commonly used parameters for each material type (as shown in the 'materials' rollout in the screengrab) arranged in a fixed layout.

Advanced :
The user can choose to view a specific parameter from a dropdown list for each material type. The user can also choose which material types to view.

I'm sure there's probably a more straight-forward way to arrange things, but this is the best I have come up with so far. If you have any suggestions... lets hear them!

http://www.reformstudios.com/03-resources/MatLister/MaterialLister_03.jpg

abyjoe
03-08-2006, 06:17 PM
is there anyway to show the final blend result of the material in the viewport. right now i dont know how to do that. you can display either of the three materials like Diffuse0, Diffuse1 or the alpha but not the end result. It only shows in the render. is it possible to show the final blend in viewport.

reForm
03-08-2006, 10:14 PM
I dont think its possible to view a blend map in the viewports.

reForm
03-15-2006, 08:51 AM
Yet another update.... :)

All materials now have basic controls.
Vray materials have a dropdown to choose map parameters (currently only reflection and refraction)
Advanced mode not implimented yet.
http://www.reformstudios.com/03-resources/MatLister/VRayMatList_0_33.ms

The parameters aren't labelled yet, so, for the vray materials, from left to right :-

S - Select objects with material
A - Apply to selected objects
E - Edit material in editor
O - switch off material/maps in viewports
Colour swatch (diffuse)
> - edit diffuse map in editor
Diffuse map selector
Diffuse map amount spinner

Reflection colour
> - edit reflection map in editor
reflection map selector
reflection map amount spinner
reflection glossiness amount spinner
reflection glossiness subdivs spinner
Fresnel Checkbox
Include in Irradiance checkbutton
Depth spinner


Let me know how you get on.

reForm
08-01-2006, 12:22 AM
A wee update for y'all.

I've fixed a few bugs, and set the default view to only show the vray materials in the scene.
Easy access to refraction and reflection values, maps, and toggles.

Please reply with any bugs or problems.... or if you need any explanations of what the controllers do!

www.reformstudios.com/03-resources/MatLister/VRayMatList_0_36.ms (http://www.reformstudios.com/03-resource/MatLister/VRayMatList_0_36.ms)

At the moment, its only the vray material that is supported fully(kind of), but feel free to have a look around at the others.... I think some of the other map types might work too.

Cheers
Pat.

reForm
08-02-2006, 01:15 AM
Some more improvements.

Interface simplified dramatically.
Filtering speeds up refresh rate.
Vray materials and maps now fully working. I will now be able to progress with getting the rest of the material types working.

I think this is now useable and handy for vray users. Please download it and give it a go. Let me know if you come across any bugs, or if you have any suggestions on how to improve the interface.

http://www.reformstudios.com/03-resources/MatLister/VRayMatList_0_37.ms

Also, if there are any maxscript guru's out there, I'd REALLY appreciate it if you found a few minutes to look over my code to see if there are any improvements to be made. I have improved the comments, so it should make a little more sense than before! :)

Thanks!

antonv
08-02-2006, 04:11 PM
Hi reForm,

I gave it a go on a large scene with closeley to 300 vray mats and it crashed on me. I think it either ran out of memory or it has to do with vray proxies...

On a smaller scene (109 materials and no proxies) worked fine.

Any chance you could add the raytrace material to the filters? And how do you see all the materials in the scene at one time?

Thanks,
Anton

reForm
08-03-2006, 10:25 AM
Yea, I think I need someone to help me with memory management, as any large amounts of materials seems to crash max.
I've got another update to upload soon that limits the number of materials processed to only the ones in the filter which should speedup the script and make it more stable.

I'm not sure about adding the function to view all materials, as you are unlikely to need to compare parameters on different material types, and it would be dog slow to update with so many materials at once. I could add the function if enough people request it though.

So... does anyone have any advice about how to fix the bug that causes max to crash when too many materials are in the scene? :)

reForm
08-03-2006, 07:20 PM
Download the latest version of this script here :-
www.reformstudios.com/03-resources/MatLister/VRayMatList_0_39.ms

Bogged
08-03-2006, 07:35 PM
Looks like a really handy tool, but the GUI is WAY too cluttered. Make a series of menus and dropdowns, and put more space between buttons, it's too compressed, I think.

good luck
Gerd

reForm
08-03-2006, 08:43 PM
Bogged, thanks for your feedback.
I'd love to make the GUI less cluttered, but I have to admit that I am struggling to work out how to make it clearer.

I dont think the GUI would work if you have more than one line per material... so with that in mind, I have to pack as much into each line as possible. If you've seen the latest version, for vray materials, I have limited the info per material to each sub-material class; ie you can choose between viewing the diffuse, reflection, refraction, bump, opacity, displacement, translucent, etc parameters. This is pretty much the limit to what I can display per line, without the line becoming too long. Even then, for the reflective properties, Its crammed in tight.

If you can think of a better method for organising the data, I'd be really grateful if you could knock up a GUI or photoshop something to illustrate your approach.

reForm
08-03-2006, 08:59 PM
This is how the worst and best cases look; ie reflective and diffuse parameters, repectively.
http://www.reformstudios.com/03-resources/MatLister/0_39_interface.jpg

reForm
08-06-2006, 12:14 AM
Well.... I'm back with another update.

Interface changed a bit. Radio buttons to switch between material types, and to switch between sections within those materials .... maybe not the best approach, but it seems to work pretty smoothly. Any suggestions for alternative UI will be considered!

The script now supports the folllowing material types

Blend
Matte/shadow
Shellac
Vray

There is a problem with one of the parameters in the matte/shadow editor. The reflection 'additive reflection' parameter is a checkbox in the max material editor; but the parameter isn't boolean (it returns either 1 or 0), so I haven't worked out how to get my checkbox working with an integer value rather than the boolean it expects. Does anyone have a solution to this problem?

Thats all for now.
Looks like I'll have to make some big changes with the new max and vray releases...... no that I'm complaining! :)

http://www.reformstudios.com/03-resources/MatLister/VRayMatList_0_40.ms

PsychoSilence
08-09-2006, 08:27 AM
i get an error when running the script from a menu button:

-- Cannot assign to read-only variable: VMap

:(

any suggestions to fix that?

regards

Anselm

reForm
08-09-2006, 10:03 AM
Hmm.... I have the same problem.

I've no idea why the script is treated differently when run from a menu button. Can any scripters out there give any possible reasons why this should happen? Do I need to define variables/structs in a different way when running the script from a menu item?

In the meantime, I'm afraid you'll have to make do with either a keyboard shortcut, or a toolbar icon.

Thanks for the feedback Anselm.

PsychoSilence
08-09-2006, 03:36 PM
tried it with a shortcut...get the same error :(

Zbuffer
08-09-2006, 03:50 PM
HI,

Don't get that error here (either from menu, or toolbar icon)

reForm
08-09-2006, 04:13 PM
Zbuffer you genius!

Thanks for that .... did you notice that I'd names some spinner return values as the same name as a function?

Anyway, I think thats it fixed.

Download here:
http://www.reformstudios.com/03-resources/MatLister/VRayMatList_0_42.ms

There's some more parameters added to that version too.

PsychoSilence
08-09-2006, 04:58 PM
Not Found

The requested URL /03-res...MatList_0_42.ms was not found on this server.

is says :(


[edit] > copied an old URL and changed the version number...download worked...but still get the VMap error :(

reForm
08-10-2006, 09:56 AM
Ah sorry about that!

What version of max and vray are you running?

PsychoSilence
08-10-2006, 12:11 PM
here at black mountain vfx we run max 8 with vray 1.47.03 should be nothing fancy i guess...

hopefully you get rid og the problem with the VMap because i see great potential in your script! i really would like to test it and integrate it in our production pipeline for the shading artists.

cheers

anselm

reForm
08-10-2006, 12:33 PM
Ok, I've stripped out the offending piece of code.
Can you see if it works now?

http://www.reformstudios.com/03-resources/MatLister/VRayMatList_0_43.ms

PsychoSilence
08-10-2006, 02:06 PM
Hey reForm, now it works! :)

testing it right away! maybe during the day i can give a detailed review on most of the functions! if it works out you´ve got a customer :D

regards

anselm

reForm
08-11-2006, 08:18 AM
Sweet! Funny that it was a piece of redundant code that was causing the problem!

CGTalk Moderation
08-11-2006, 08:18 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.