Notifications
Clear all

[Closed] call a material editor sample slot

Hi all,
How can I call a sample slot from the material editor (the action of double clicking the)?
https://docs.google.com/file/d/0B0V4AxfEEBovQ1FWcXdZN0FPNTg/edit?usp=sharing

Thanks

8 Replies

set this slot active and call medit.GetCurMtl()

i don’t have max to check… am i missing anything?

5 Replies
(@zarko)
Joined: 11 months ago

Posts: 0

Hi Denis,
the medit.GetCurMtl() only returns the current bitmap, but it does not open the sample preview

(@denist)
Joined: 11 months ago

Posts: 0

you didn’t ask anything about a preview… what do you actually want?

do you want to launch magnify window for current material editor slot?

(@denist)
Joined: 11 months ago

Posts: 0

you can do it with only opened Material Editor


(
	MatEditor.Open()
	actionman.executeAction 2 "40296"
)
(@zarko)
Joined: 11 months ago

Posts: 0

Yes this is what I needed. Thanks again
Also is there another command that closes this magnify window?

(@denist)
Joined: 11 months ago

Posts: 0

there is no a command to close it. you can close it using UIAccessor.CloseDialog

Or you can make your own window that shows the bitmap(scaled to desired size) and then can close this window via maxscript.

Ripped from my old script. You can scale the rollout and the bitmap will scale with it. You can move the rollout by draging the bitmap with the mouse.

(
	global rol_MapPreview
	try(destroyDialog rol_MapPreview)catch()
	rollout rol_MapPreview ""
	(
		local theBMP = undefined
		local mousedd = false
		local roPos = [0,0]
		on rol_MapPreview lbuttonup pos do mousedd = false 
		on rol_MapPreview lbuttondown pos do
		(
			mousedd = true
			roPos = pos
		)
		on rol_MapPreview mousemove pos do
		(
			if mousedd do SetDialogPos rol_MapPreview  (mouse.screenpos - roPos)
		)					
		
		imgtag bm_Preview pos:[0,0] width:196 height:196 bitmap:(bitmap 1 1 color:black) enabled:off
			
		on rol_MapPreview open do
		(
			theBMP = meditmaterials[1].diffuseMap.fileName
			rol_MapPreview.title = filenameFromPath theBMP
			bm_Preview.bitmap =  (openBitmap theBMP)
			bm_Preview.width = rol_MapPreview.width
			bm_Preview.height = rol_MapPreview.height
		)
			
		on rol_MapPreview resized Point2 do
		(
			local ro_size = GetDialogSize rol_MapPreview
			--	keep rollout square
			rol_MapPreview.width = ro_size[1]
			rol_MapPreview.height = ro_size[1]			
			
			bm_Preview.width = ro_size[1] - 2
			bm_Preview.height = ro_size[1] - 2						
			--	rollout can't be smaller than 196x196 px
			if rol_MapPreview.width < 196 do rol_MapPreview.width = 196
			if rol_MapPreview.height < 196 do rol_MapPreview.height = 196
		)
		
		on rol_MapPreview close do
		(
			freeSceneBitmaps()
		)
	)
	createDialog rol_MapPreview 196 196 style:#(#style_sysmenu,#style_toolwindow,#style_resizing)	
)
1 Reply
(@zarko)
Joined: 11 months ago

Posts: 0

This is fine, but the reason I need the sample preview is because I need to see the texture after I change the RBG offset spinner and invert checkbox.
You can see the image below:
https://docs.google.com/file/d/0B0V4AxfEEBovVFpqS19TUGlrZ3c/edit?usp=sharing