MS to resize an object's texture map

Hi everybody!

I'm new here and totaly new to maxscripting.

I've looked around and it seems possible but no clue how to get
it going. I'm looking for a script that will allow me to resize
the bitmap texture of a selected object.

For example a cube in scene has an 512x512 diff map assigned to
it and I would like to bring it down to 128 x 128

If anyone can steer to a right direction it would be much
appreciated.

Thank you!

RK

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Rokhound's picture

Thanks! I think the problem

Thanks! I think the problem is if I execute with the numPAD enter.

When I drag drop the script it seems to work fine.

miauu's picture
Rokhound's picture

Sure thing, will send it

Sure thing, will send it shortly. I'm using Max 2013.

miauu's picture

Can you upload the test

Can you upload the test scene? Which max version?.

Rokhound's picture

Thank you for the quick

Thank you for the quick response Miauu

I went through it and slowly understanding scripting better.

But when I ran it I got this error from the listener:

-- Error occurred in anonymous codeblock; filename: ; position: 818; line: 28
-- Syntax error: at ), expected
-- In line: )

I can't seem to find the answer anywhere :/

miauu's picture

Try this:

(
	local newMapSize = [128,128]
	local curObj = selection[1]
	local diffuseMapPath = curObj.material.DiffuseMap.filename
	--	slower but with better quality
	local texMap = bitmaptexture bitmap:(openBitmap diffuseMapPath)
	local theNewMap = renderMap texMap size:newMapSize filter:on
 
	/* 
	--	faster but with lower quality
	texMap = openBitmap diffuseMapPath
	theNewMap = bitmap newMapSize.x newMapSize.y
	copy texMap theNewMap
 
	*/
 
	--	show map in VFB
-- 	display theNewMap
	--	this will override the original diffuse map
	theNewMap.filename = diffuseMapPath
	save theNewMap
	close theNewMap
	freeSceneBitmaps()
 
	--	assign the resized map
	curObj.material.diffuseMap = Bitmaptexture bitmap:(openBitmap theNewMap.filename)
	showTextureMap curObj.material curObj.material.diffuseMap on
)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.