Notifications
Clear all

[Closed] class of different materials

I’m working with revit files in 3ds max 2012, these files come in with autodesk materials attached ie “Autodesk Generic”, “Autodesk Concrete”. What I’m trying to do is print out some information about each material. As each different material has different attributes I’m trying to initialy see what type of material it is. So far I have found out how to print the material if it is a standard material, yet I cannot find the correct phrase for different types of materials which would replace the phrase “standard” in the code below, specifically the range of autodesk materials.

for varMat in scenematerials do
(
if classof varMat == standard then
(
print varMat
)
)

Any help would be appreciated, I have googled but with out any luck. I'm very new to maxscript coming from a background of maya/mel.
6 Replies
 here is a sample function that print material classes info:

     fn showMaterialClasses showProps:off asStream:off sorted:#none = 
     (
     	fn sortByClass c1 c2 = stricmp (c1 as string) (c2 as string)
     	fn sortByName c1 c2 = stricmp c1.localizedName c2.localizedName
     	fn sortByCategory c1 c2 extraSort:sortByClass = if (a = stricmp c1.category c2.category) != 0 then a else extraSort c1 c2
     		
     	classes = material.classes 
     	case sorted of
     	(
     		   #class: qsort classes sortByClass
     		    #name: qsort classes sortByName
     		#category: qsort classes sortByCategory
     	)
     	
     	ss = if asStream then stringstream "" else newscript()
     
     	for class in classes do 
     	(
     		format "Class: %
Category: %
ClassID: %
Name: %
Creatable: %
" (class as string) class.category class.classID class.localizedName class.creatable to:ss
     		if showProps and class.creatable do 
     		(
     			format "Properties:
" to:ss
     			showproperties (createinstance class) to:ss 
     		)
     		format "
" to:ss
     	)
     	
     	if asStream do
     	(
     		clearlistener()
     		format "%
" (ss as string)
     	)
     	classes.count
     )
     /*
     showMaterialClasses()
     showMaterialClasses sorted:#category
     showMaterialClasses showProps:on asStream:on sorted:#name
     */
     

Thanks for the replys, I think I’m getting somewhere, the phrase I was looking for was “Autodesk_Material” which covers all of the autodesk materials. The next problem I have is that the node connected into the materials which have the texturemaps attached to are “Autodesk Bitmap” nodes as opposed to normal “Bitmap” nodes and I am unable to find a way of queering which texture map is connected to the Autodesk map nodes.

The following works correctly if normal bitmap nodes are used

    for varMat in scenematerials do
    (
    if classof varMat == Autodesk_Material then
    (
    print varMat
    )
    if hasProperty varMat "Generic_Image" then
    (
    if classof varMat.Generic_Image == Bitmaptexture then
    (
    varGenericTextureName = filenameFromPath(varMat.Generic_Image.filename)
    print varGenericTextureName
    )
    )
    ) 
  
however with the autodek node it can't find the property .filename and I can't find the equilavant. This is what I have so far, it finds the autodesk bitmap node but can't find the name of the attached texture map

    for varMat in scenematerials do
    (
    if classof varMat == Autodesk_Material then
    (
    print varMat
    )
    if hasProperty varMat "Generic_Image" then
    (
    if classof varMat.Generic_Image == Autodesk_Map then
    (
    varGenericTextureName = filenameFromPath(varMat.Generic_Image.filename)
    print varGenericTextureName
    )
    )
    )
     

Have you tried selecting an object in your scene that has an Autodesk_Material with an Autodesk_Map and typing into the listener?

show $.material.Generic_Image

Thanks for that. It turns out the phrase to replace “.filename” should be “.Parameters_Source” making the code


        for varMat in scenematerials do
        (
        if classof varMat == Autodesk_Material then
        (
        print varMat
        )
        if hasProperty varMat "Generic_Image" then
        (
        if classof varMat.Generic_Image == Autodesk_Map then
        (
        varGenericTextureName = varMat.Generic_Image.Parameters_Source
        print varGenericTextureName
        )
        )
        )
I have taken out the "filenameFromPath" as that doesn't work with the Parameters_Source

Try inserting the line:

varGenericTextureName = varMat.Generic_Image.Parameters_Source
print (classOf varGenericTextureName)
print varGenericTextureName

It will tell you what class .Parameters_Source is.