Notifications
Clear all

[Closed] How to make a MapButton?

Hi I’m trying to create a MapButton that is “wired” to a bitmap in the Material Editor.

So when I click the MapButton and choose a bit map then that bitmap should also be chosen as a bitmap in the material editor.

The CODE:

The bitmap in the material editor n that I want to change when i click on the map button.

The MapButton

Thanks in advance (:

5 Replies

that is what the help says:

[left]When a mapButton is used in a rollout in a scripted material or textureMap plug-in, and so turn up the Material Editor, it behaves with the same functionality as sub-map buttons do in other materials and maps. This includes supporting drag-and-drop with instance/copy, and opening sub-maps if they have been assigned.
[/left]
[left]
But the help doesn’t say that when the mapButton used in a rollout of a scripted material it loses the button’s picked event. So in this case you have to use parameter’s set event to apply the picked texturemap:


 plugin material _Standard name:"_Standard"
 	classID:#(1967,0xABCEAA01L)
 	extends:Standard
 	replaceUI:on 
 	autoPromoteDelegateProps:on
 (
 	parameters main rollout:main
 	(
 		texture type:#texturemap ui:ui_texmap
 		on texture set val do
 		(
 			format "texture:%
" val
 			diffusemap = val
 		)
 	)
 	rollout main "Parameters" 
 	(
 		label lb_texmap "Diffuse Texture:" align:#right offset:[-50,2] across:2
 		mapbutton ui_texmap "None" width:200 align:#right offset:[4,-2]
 	)
 )
 

[/left]

Thank you for your help (:

But I getting an error when I try to run the code(probably i’m doing something wrong )

CODE:

ERROR: (open in new window/tab for full res img)

you are doing everything wrong. first of all you are showing only part of your code and we have to guess about another.
you want to use mapbutton in CA rollout. so what i said above doesn’t make sense.
in CA rollout a mapbutton works normal way. you can use both button’s picked event and parameter’s set event.

1 Reply
(@patan77)
Joined: 11 months ago

Posts: 0

Hi thank you for you taking your time to try helping me. (:

I did actually think that I did the most part wrong because i didn’t really understand the code, (I’m new to max script, this is my first max script). So you are saying that I don’t have to do as in your code example above?

btw: I didn’t show all code because I though that It would be easier if I only give the important part of the code, the whole code is 780 lines, but I upload it now as a txt file:

Link whole code: http://www.patan77.com/help/Head-Script-2011-11-10.txt

can’t I do something like this?(Image below )

CODE in Maxscript listener:

And again thanks for your time.

you have to figure out yourself what part of your code to provide with your question to get a clear and quick answer.
well… as I said both evens (button’s and parameter’s) work for mapButton control in CA rollout.
here is a sample:


global diffuseCA = attributes diffuseCA
(
	fn getNode = (refs.dependentnodes (custAttributes.getowner this) firstonly:on)
	parameters main rollout:main
	(
		texture type:#texturemap ui:ui_texmap
		on texture set val do
		(
			format "set texture:%
" val
			if (node = getNode()) != undefined and iskindof node.mat Standard do node.mat.diffusemap = val
		)
	)
	rollout main "Textures" 
	(
		label lb_texmap "Diffuse Texture:" align:#left offset:[0,0] 
		mapbutton ui_texmap "None" width:150 align:#center offset:[0,0]
		
		on ui_texmap picked tex do if tex != undefined do
		(
			format "picked texture: %
" tex
		)
	)
)

/*
--delete objects
(
	s = sphere isselected:on
	s.mat = Standard showinviewport:on
	custattributes.add s diffuseCA baseobject:on
)
*/

don’t ask me how it works. try to understand it yourself, read mxs help, browse in this forum… without your own understanding you will not be able to use it in your development.