Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Different evaluation of Rollout size in Script Editor window vs Macro on Menu

Different evaluation of Rollout size in Script Editor window vs Macro on Menu

10DSpace
Advisor Advisor
1,053 Views
6 Replies
Message 1 of 7

Different evaluation of Rollout size in Script Editor window vs Macro on Menu

10DSpace
Advisor
Advisor

I have been trying to create a rollout whose height is based on the number of objects selected by the user.  The objects selected are displayed in a multilistbox and below that are 3 buttons.   The line of maxscript that specifies the height of the rollout is:

 

-- Create the rollout with a dynamic height value that adjusts to the initial selection set count

rollout Isolate_Plus "Isolate Plus" width:180 height:(selection.count * 16 + 130)

 

When I run the script from the script editor (using Evaluate Line Selection) I get exactly what I want, the rollout scales appropriately based on the number of selected objects.  However, when I run the same script as a macro in a menu, the size does not scale and the box is greatly truncated and the 3 buttons are not available (see below).

 

Maxscript_Dynamic Menu.png

 

It appears that the first part of the height term,  (i.e., “selection.count * 16” ) is recognized by the script editor as I want, but is evaluated differently (i.e., ignored) when max loads the macro at start up.

 

So my questions are:

  1. Why and how exactly is the script evaluation by Max different in the Script Editor window vs the max startup/macro load process?
  2. Is there a simpler and better way to scale the height of a rollout based on the number of selected objects displayed in a multilistbox on a rollout?

 

Any help would be appreciated.

 

0 Likes
Accepted solutions (1)
1,054 Views
6 Replies
Replies (6)
Message 2 of 7

10DSpace
Advisor
Advisor

Also, by loading the .ms version of the script in a separate macro with the following code:

 

if doesFileExist (pathConfig.GetDir #usermacros+"\\Isolate_plus3.ms") then
fileIn (pathConfig.GetDir #usermacros+"\\Isolate_plus3.ms")
else
messagebox "Can't locate the script" title:"ERROR!!!"

 

I can work around the different evaluation of the original macro (Isolate_plus3.mcr) by Max start and macro load process.   While this is a viable alternative solution for me, I am hoping to gain a better understanding of scripting issues by answers to the 2 questions above.    Thanks for any guidance on this.

0 Likes
Message 3 of 7

istan
Advisor
Advisor
Accepted solution

You could also resize the dialog/rollout in the 'on Open' function..

Message 4 of 7

10DSpace
Advisor
Advisor

@istan 

 

Thanks.  I had overlooked the "On Open" command and interestingly that survives the max startup/load macro process in the macro.  Do you have any insight into why the same mathematical expression is processed differently when in the initial rollout height declaration: 

 

rollout Isolate_Plus "Isolate Plus" width:180 height:(selection.count * 16 + 130)

 

vs  a few lines later:

 

On Isolate_Plus open do
(
Isolate_Plus.height = (selection.count * 16 + 130)
)

 

Maybe it has something to do with the fact that at the time of loading the macro at startup, the selection.count term is meaningless but that after the rollout is called up in a scene it has a definite value?    

 

Thanks again for your suggestion.

0 Likes
Message 5 of 7

istan
Advisor
Advisor

@10DSpace wrote:

@istan 

 

Maybe it has something to do with the fact that at the time of loading the macro at startup, the selection.count term is meaningless but that after the rollout is called up in a scene it has a definite value?    


 

This is what I also thought, but for me the window is not 130 pixels high?! I usually omit any calculations in the rollout line.. I restore dialog settings (pos, size, rollout state..) always from a cfg file..

Message 6 of 7

10DSpace
Advisor
Advisor

@istan 

 

Thanks.  I never played around with config files, but it is worth looking into.  I guess you are just using the .ini functions described here?:

 

https://help.autodesk.com/view/3DSMAX/2017/ENU/?guid=__files_GUID_CF408D64_D4E2_4C39_90DB_62E525D7B4...   

0 Likes
Message 7 of 7

istan
Advisor
Advisor

I use another approach (leaned from bobo). I simply write MXS code in the cfg file and use execute(), as then I have access to all of my dialog controls and data directly from the cfg file..