Notifications
Clear all

[Closed] Dynamic rollout button size

 bks

Hello all, newbie here, please be gentle.

I’m currently updating a very old basic script that I once created yonder ago after watching a YouTube video I can no longer find.

I created a very basic rollout, with a few buttons to call functions like, creating a plane/tube, and different modifier/sub-modifier functions, like removing edges, selecting loop or ring, converting meshes to editable poly, using functions like “collapse” in vert edit mode or “bridge” in edge edit mode.

At the time, I had no real understanding of creating code or programming. Currently I go to college to study programming, so I have picked up the interest in making a version two of this script. In that quest, I want the buttons within the rollover to resize to half the width of the rollover. however my attempt at not hard-coding these values has failed.

I setup two variables at the top of the script, one called maxwidth, the other maxheight.

The look like this:

var maxwidth = 250/2
var maxheight = 30

I would like to know how I can fix this so that the size of the buttons will dynamically resize based upon the rollout size.

Thanks in advance! I have included a snippet of the code below.

var maxwidth = 250/2
var maxheight = 30

try (closeRolloutFloater ToolkitFloater) catch()

rollout Toolkit “BkS’ Quick Toolkit”
(
button plane “Plane” pos:[3,40] width=maxwidth height=maxheight

on plane pressed do
 (
 plane()
 )
)
ToolkitFloater = newrolloutfloater “Quick Tools” 250 340
addrollout Toolkit ToolkitFloater

9 Replies

size is not be accessed after created , you need dotnet controls

 bks

Could you explain a bit more in laymen terms please?

you can search dotnet , there are lots of examples

you can also set control size directly

try (destroydialog X ) catch ()
rollout X "" (

	button btn "button"
	
	on x resized size do 
	(
		rect = windows.getWindowPos btn.hwnd[1]
		rect.w = size.x
		offset = 5
		
		windows.setWindowPos btn.hwnd[1] offset offset (rect.w - offset * 2) rect.h true
	)

)
createDialog X style:#(#style_resizing, #style_titlebar, #style_border, #style_sysmenu) 

For 3ds Max 2019 and above

try (destroydialog X ) catch ()
rollout X "" (

	button btn "button" pos:[5,5]
	
	on x resized size do 
	(
		btn.width = size.x - 10
		btn.height = size.y - 10
	)

)
createDialog X style:#(#style_resizing, #style_titlebar, #style_border, #style_sysmenu)

they update the properties in 2021 ?

Max 2019 +

I checked it in 2019 manual , not update them

In Max2019 the code works with no errors.
This will not be the first time when something is not in the maxscript Help file but works inside 3ds Max.