Home Technical Talk

Maxscript: How to enable a button from a custom material?

My company has a custom .fx 3d  Max material and I'm trying to hack together a script to automatically assign texture to it. I have it working however the box with the texture name is "disabled" and I'm trying to figure out how to enable it. I don't really even know what to search for. 

 

This is the code from the material rollout

group "Base"
(
 checkbox      cbox_diffuse        "Diffuse . . . ."  	    align:#left across:3 offset:[0,0]
  mapbutton     b_diffuse           "None"             	    enabled:false align:#left height:16 width:190 offset:[-20,0] 
)
The basic test of what Im doing is this. Asking for a file via prompt and assigning it.

n askForfile =
(
	fileD = getOpenFileName caption: "Pick ur D:" \ 
									types:"Targa(*.tga)" \
)

fn assignDiffuse = 
(
	
	meditMaterials[curMet].g_DiffuseTex = Bitmaptexture fileName:fileD
	meditMaterials[curMet].g_bDiffuseMap = on

)

The thing that is confusing to me is the listener calls the diffuse "g_DiffuseTex" and in the actual .ms its called "b_diffuse"? The scripts are kind-of a mess and I'm a newb so that is a bad combo. I'm not sure what other info would be helpful without posting the whole mess of scripts. I'll post what I can without getting into trouble. 

Replies

  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    its g_DiffuseTex as thats whats the texture sampler called in the shader. Pretty sure as I wrote something back at my old job where it accessed engine materials and was setting it up in max. It might be  disabled because of this? (enabled is set to false): mapbutton b_diffuse "None" enabled:false
    This WYSWIG editor is funky :( haha
  • monster
    Options
    Offline / Send Message
    monster polycounter
    Haiddasalami, is right about b_diffuse being disabled. I assume you are not allowed to change that part though.

    But really you don't even need to enable b_diffuse to work just do something like this:

    (medit.GetCurMtl()).RolloutName.b_diffuse.picked (bitmaptex filename:pathToFile)

    This will make Max think you pressed the button.
  • nyx702
    Options
    Offline / Send Message
    @haiddasalami 
    I tried enabling it but I'm not sure if I was doing it right or if it just doesn't work. I tried 
    meditMaterials[curMet].b_diffuse.enabled  = true
    and
    meditMaterials[curMet].g_DiffuseTex.enabled = true

    but neither of those worked. The listener said, "Unknown property: "enabled"

    @monster

    Awesome! That is what i was looking for but couldn't find out how to "press" a button... How do I find the RolloutName I need? Is there an easy way to do this in max without opening the script file? I tried the displayed name but that didn't work. 

  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    Try this Nick. 
    meditMaterials[curMet].g_DiffuseTex = openBitmap "Insert Path to test"
    That should load a texture to that sampler. Guessing this is a scripted material plugin? Hard to debug from here but not sure if you know but you can do for example

    b = medit.GetCurMtl()
    show b


Sign In or Register to comment.