[Closed] Modifier Enable/Disable ModPanel redraw
we can enable/disable a modifier by <modifier>.enable = on/off
can anyone suggest the simplest and minimum flicker way to update the state in the modifier panel?
i see only way to update is to reset current object. but causes a lot of issues: flicker, loosing current selection, loosing sub-object mode, etc.
also an enabled/disabled modifier can be not on top of stack. the setting current edit object doesn’t make sense in this case
What about rightclick + leftclick on modifiers listbox?
It blinks for a fraction of a second, but otherwise it does seem to work
(
delete objects
g = GeoSphere isselected:on
addModifier g (Edit_Poly())
max modify mode
subObjectLevel = 4
gc();t1=timestamp();hf = heapfree
hwnd = for c in windows.getChildrenHWND #max where UIAccessor.GetWindowResourceID c[1] == 1689 do exit with c[1]
if hwnd != undefined do
(
$.modifiers[1].enabled = not $.modifiers[1].enabled
$.modifiers[1].name = random 1231 68465465 as string
windows.postMessage hwnd 0x204 0 0
windows.postMessage hwnd 0x205 0 0
windows.postMessage hwnd 0x201 1 0
windows.postMessage hwnd 0x202 0 0
)
format "Time: %sec. Mem: %
" ((timestamp()-t1)/1000 as float) (hf-heapfree)
)
Or this:
WM_RBUTTONDOWN = 0x0204
WM_LBUTTONDOWN = 0x0201
listbox_hwnd = /*0x00000000*/
max_hwnd = windows.getmaxhwnd()
windows.postmessage listbox_hwnd WM_RBUTTONDOWN 0 0
windows.postmessage max_hwnd WM_LBUTTONDOWN 0 0
The problem with this is that it scrolls the listbox to the selected subobject. But there might be other messages that trigger the same action.
It also adds the first modifier to current modifier selection and scrolls to that first modifier – btw. if shortened to sending only the two events, it also enters sort of drag+select mode when in subobjectlevel. In that, it’s not that much better than suspendEditing which:#modify + resumeEditing which:#modify
I really don’t see anything better than just
modPanel.setCurrentObject(modPanel.getCurrentObject())
This migh be better:
$.modifiers[1].enabled = not $.modifiers[1].enabled
$.modifiers[1].name = random 1231 68465465 as string
notifyNumSubObjs = (
local max2016 = (maxVersion())[1]/1000 < 19
local compilerParams = dotNetObject "System.CodeDom.Compiler.CompilerParameters" #(
getDir #maxRoot + "Autodesk.Max.dll",
getDir #maxRoot + "MaxPlusDotNet.dll")
compilerParams.GenerateInMemory = true
local compilerResults = (dotNetObject "Microsoft.CSharp.CSharpCodeProvider").CompileAssemblyFromSource compilerParams #(
"using System;
using Autodesk.Max;
using Constants = Autodesk.Max.MaxPlus.Constants;
using PartIds = Autodesk.Max.MaxPlus.ReferenceMessagePartIds;
public static class Const {
public static readonly IGlobal Global = Autodesk.Max.GlobalInterface.Instance;
public static IInterval FOREVER = Global.Interval.Create();
static Const() {
FOREVER.SetInfinite();
}
}
public class Notifications {
public static void NotifyNumSubObjs(System.UIntPtr handle) {
IReferenceTarget obj = (IReferenceTarget)Const.Global.Animatable.GetAnimByHandle(handle);
obj.NotifyDependents" + (if max2016 then "_" else "") + "(Const.FOREVER, UIntPtr.Zero, RefMessage.NumSubobjecttypesChanged, (SClass_ID)Constants.NotifyAll, true, null" + (if max2016 then "" else ", NotifyDependentsOption.DisallowOptimizations") + ");
}
}"
)
for err = 0 to compilerResults.errors.count - 1 do print (compilerResults.errors.item[err].ToString())
local notifications = compilerResults.CompiledAssembly.CreateInstance "Notifications"
notifications.NotifyNumSubObjs
)
notifyNumSubObjs(getHandleByAnim $.modifiers[1])
yes… this is what i’m using:
NotifyDependents(FOREVER,0,REFMSG_NUM_SUBOBJECTTYPES_CHANGED);
on mxs level the best I could find is:
(
type = subobjectlevel
subobjectlevel = if type > 0 then 0 else 1
subobjectlevel = type
)
but “subobjectlevel” solution doesn’t help with modifier renaming
still not working with multiple modifiers selection, but now it doesn’t select the first one
windows.postMessage hwnd 0x204 0 0
windows.postMessage hwnd 0x205 0 0
windows.postMessage (UIAccessor.GetParentWindow hwnd) 0x201 1 0
windows.postMessage (UIAccessor.GetParentWindow hwnd) 0x202 0 0