View Full Version : Export obj-material or scene materials to .mat
04-25-2008, 08:02 AM
Aaand...yet another question ;)
How can I export the material of a selected object - or more selected ones - to a single .mat file? The MaxScript help isn't that helpful, since there's only described a way how a material can be appended to an existing .mat file.
This way would shorten the process shown in the attached image below tremendously:
Next will be, to collect all materials from the scene and export them to a .mat-file.
Thank you in progress for your help. :wip:
04-25-2008, 09:09 AM
You can access the material library by using currentMaterialLibrary global. So you can reset this material table (loadDefaultMatLib() or loadMaterialLibrary), append materials and save it using saveMaterialLibrary.
See "MaterialLibrary Values" in the MAXScript Reference.
04-25-2008, 09:37 AM
But this way, I would have to put the material in a slot of the material editor first, to read it from the currentMaterialLibrary global.
meditmaterials = $Box01.material
That's the point I want to walk around.
04-25-2008, 10:09 AM
Well, I can't really understand the problem but you don't need to use the meditMaterials global, you can directly append materials to the currentMaterialLibrary global:
append currentMaterialLibrary $Box01.material
To access it:
$Box01.material = currentMaterialLibrary
04-30-2008, 08:06 AM
I developed a short script for a scene export of all materials, but encounter one problem.
on btn_export_scenemat pressed do
local exp_scenemat_array = #()
exp_scenemat_array = for exp_scenemat_obj in $* where exp_scenemat_obj.material != undefined collect exp_scenemat_obj
for i=1 to exp_scenemat_array.count do
append currentMaterialLibrary exp_scenemat_array[i].material
I need to reset the default material library first, before I can export it, to prevent max from exporting all materials again, if I want to export only one material, with another routine I wrote.
Is there a function or construct for resetting the 'DefaultMatLib' ?
04-30-2008, 04:43 PM
If you are working on max 9 or higher besides using the default material library you can use custom material libraries. For that you would have to define your own material library variable, append your materials and then save it using saveTempMaterialLibrary(). Failing that you can alway reset the current material library by loading an empty .mat for example, but I think the first option is what you are looking for.
Besides that you also have the sceneMaterials material library that holds all the materials in the current scene. Itīs a bit buggy but if you are trying to save the scene materials it could be faster than just creating your own array.
On a side note, I am currently working on a material manager, currently in beta stages, that uses .mat files to store the userīs materials (see pic), so let me know if I can be of help... Iīve already hit all kinds of walls down this path =)
05-05-2008, 09:30 AM
Thank you for your tips. Since I want to keep this tool compatible with older versions of max since version 9, loading an empty .mat would be the best option.
... Failing that you can alway reset the current material library by loading an empty .mat for example, but I think the first option is what you are looking for. ...
What do I need to do to load an empty .mat file? - Is it necassary to create an empty one first? Is there no option to reset the DefaultMatLib?
05-05-2008, 12:48 PM
Another one would be to do something along the lines of:
FOR mat = 1 to currentMaterialLibrary.count DO
deleteItem currentMaterialLibrary 1
05-05-2008, 12:48 PM
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.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.