PDA

View Full Version : Change Interaction mode Script


fm3d
01-03-2016, 05:37 PM
Hello. I'm new to MAX Script, and Im trying to do a script for changing the Interaction mode in 3DSMax without using: "Customize menu -> Preferences -> Interacion Mode -> ..."

My Macroscript for this is:

macroScript InteractionModeSwitch
category:"DragAndDrop"
toolTip:"Interaction Mode Switch"
(
fn getFile = "C:\Users\fmsuarez\AppData\Local\Autodesk\3dsmax\20 13 - 64bit\ENU\3dsmax.ini"
fn getIni = getINISetting (getFile()) "InteractionModeSection" "InteractionMode"
fn setIni = setINISetting (getFile()) "InteractionModeSection" "InteractionMode" ( if (getIni()) == "3dsMax" then "Maya" else "3dsMax" )

On IsChecked Return (If (getIni() == "Maya") do return true)
On Execute do setIni()
)

This one changes the Interaction Mode value, but the change has no effect for navigation in the viewports.
Any help is welcome. Thank you.

insect
02-03-2016, 12:55 PM
It is quite likely that max reads the .ini file only when loading the UI, so whatever you change in it might not have immediate results. And your changes may be overwritten when max decides to save its effective settings to the ini file.

Have you tried changing the value using IInteractionMode.CurrentMode?
See MAXscript help for more: http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwiZ8c_UhaLLAhXqF5oKHSzDA20QFggdMAA&url=http%3A%2F%2Fdocs.autodesk.com%2F3DSMAX%2F16%2 FENU%2FMAXScript-Help%2Ffiles%2FGUID-99E9991F-E246-41C8-A76F-AF5F341A1A52.htm&usg=AFQjCNEDLrQVoTKWU_30HHHuckDZxYAI2w&sig2=feIroueqH7ZP6yEDkxxEMw&cad=rja

I'm also a little puzzled why call a function that only returns a constant string... Wouldn't a variable have been enough?

fm3d
02-03-2016, 06:28 PM
Thank you very much for your help "insect". The .ini file modified with my script works as you say.
I have used the "IInteractionMode.CurrentMode" command and now I've gotten it to work the way I wanted.

The new MacroScript is:

macroScript InteractionModeSwitch
category:"DragAndDrop"
toolTip:"Interaction Mode Switch"
(
fn currentimode = IInteractionMode.CurrentMode
fn setcurrentimode = (if (currentimode()) == #3dsMaxMode then (IInteractionMode.CurrentMode = #MayaMode)
else (IInteractionMode.CurrentMode = #3dsMaxMode))

On IsChecked Return (If (currentimode() == #MayaMode) do return true)
On Execute do setcurrentimode()
)

fructose
03-03-2016, 12:48 AM
It is helpful to me, I leart it. thanks