MaxScript Get texture size and Mapbutton

Hi,

I want to get a texture size via maxscript. I am getting that texture via getOpenFileName and will never be assigned on a material. I just can’t find anywhere any properties I could use for that but I would be very surprise they don’t exist !

Also, before using a getOpenFileName I tried using a mapbutton, but it seems I can’t find how to properly use it, I would expect it return me a path just like getOpenFileName but wrapped in a nicer UI (which would be ideal for what I want to do), but no, all I can get from it is things like : “Map #9” . If someone have some explanation about this one too I would be very happy =) .

Thanks!
Bloby

You can take the return value from getOpenFileName and use OpenBitmap function to open it. Then you will have access to the width and height of the texture.

Here’s a sample code to get you started:

tex = getOpenFileName()
bmpTex = openBitmap tex

format "Width:% Height:%
" bmpTex.width bmpTex.height

Superb, thanks ! :slight_smile: