Notifications
Clear all

[Closed] How to set a specific layout with maxscript

Hi there.

I’ve just started using maxscript for a couple of days, because I want to make my workflow a little bit faster, and the first task I’d like to get done is setting a layout.

I already know that viewport.setLayout changes the number of viewports and how they are arranged, and viewport.setType change the current viewport to an orthographic or perspective view, but I can’t figure how do I change each viewport individually on maxscrpit.

So this might be very easy but I don’t know the answer. Thanks in advance

2 Replies

Hi check out this script let me know if it works for you


  macroScript MaxScripterUi
  category:"MaxScripterUi" 
  tooltip:"UI for max scripting"
  Icon:#("Maxscript",2)
  (
  	rollout maxScripterUi "MScripter" width:68 height:60
  	(
  		button btnCreateUI "Create UI" pos:[4,4] width:60 height:24
  		button btnReset "Rset Ui" pos:[4,32] width:60 height:24
  		
  		on btnCreateUI pressed do
  		(	
  			try 
  			(
  				if viewport.numViews == 1 then ( max tool maximize )
  				viewport.setLayout #layout_2v
  				viewport.activeViewport = 2
  				viewport.setType #view_persp_user
  				viewport.activeViewport = 1
  				actionMan.executeAction 0 "40408" --add maxscript listener as extended viewport
				actionMan.executeAction 0 "40839" --open maxscript editor
  			)
  			catch()
  		)
  		
  		on btnReset pressed do
  		(
  			viewport.ResetAllViews()
  			max tool maximize
  
  		)		
  	)
  	createDialog maxScripterUi	
  )
  
  

Thanks Arahnoid for replaying my post, I try to run the script you wrote but the only thing that it does in my Max (Working on 3ds Max 2010) is open the max listener. Or how do you suggest me to run the code?

Reading the script makes me think that it creates a rollout where two buttons make the actions, but I didn’t see any come to my UI.

Fortunately, I solved my problem by writing this script:


--Set Viewports
viewport.setlayout #layout_3vl
viewport.activeViewport = 1
viewport.setType #view_camera
max safeframe toggle
viewport.activeViewport = 2
viewport.setType #view_top
viewport.activeViewport = 3
viewport.setType #view_persp_user

Pritty simple, but it works

Thanks