Home Technical Talk

[Maxscript] meditMaterials opacity error

fascinate4
null
Hi.

I am getting "--Type error: Call needs function or class, got: 100.0", when I am trying to use my sript which should write opacity parameters of selected texture in file. I don't know what I should write to make it work correctly.


 local found = 0
            local objMat = selection[1].mat			
			for i = 1 to meditMaterials.count where found == 0 do
            if meditMaterials[i] == objmat then found = i
            found -- contains the index of the material slot, or 0 if it was not found
			
			--local Mnames = GetMeditMaterial found as string
			for Mname=1 to found do
			(
				Mnames = GetMeditMaterial Mname as string
				Opty = meditMaterials[1].opacity Mname as integer
				format "%" Opty to:file01
				format "\n" to:file01
				format Mnames to:file01
				format "\n" to:file01
			)<span class="post-color-blue"></span><span class=""><span class="post-color-blue"></span></span>

Replies

  • Noors
    Options
    Offline / Send Message
    Noors greentooth
    Opty = meditMaterials[Mname].opacity 
    Do you just want to save the material opacity of your selected object ?
    You could just do :
    <code>matOpacity = myMat.opacitymyMat = selection[1].mat<br>matName = myMat.name<br>
    No need to deal with the material editor.


  • fascinate4
    Options
    Offline / Send Message
    fascinate4 null
    Noors said:
    Opty = meditMaterials[Mname].opacity 
    Do you just want to save the material opacity of your selected object ?
    You could just do :
    <code>matOpacity = myMat.opacitymyMat = selection[1].mat<br>matName = myMat.name<br>
    No need to deal with the material editor.


    Thank you. I want that script will show opacity of all used material on selected model.
  • Noors
    Options
    Offline / Send Message
    Noors greentooth
    An object can't have multiple materials so i assume you talk about multimaterial ?
    If so, you need to parse it, like an array.
    This covers the case, and works with  multiple objects selection. I've added some security checks.
    (
    sel = selection as array

    for obj in sel do
    (
    myMat = obj.mat

    if myMat != undefined then
    (
    if classof myMat == Multimaterial do
    (
    for m in myMat where classof m == Standardmaterial do
    (
    format "material name : %\n" m.name
    format "material opacity : %\n" m.opacity
    )
    )

    if classof myMat == Standardmaterial do
    (
    format "material name : %\n" myMat.name
    format "material opacity : %\n" myMat.opacity
    )
    )
    else format "% is not a valid selection\n" obj.name
    )
    )


    </code><code>



Sign In or Register to comment.