Posted By

vsai on 12/15/08


Tagged

viewport maxscript dialogmonitorOps


Versions (?)

toggle the Use Cached D3DXMeshes Viewport


 / Published in: Maxscript
 

  1. toolTip="toggle the Use Cached D3DXMeshes Viewport"
  2. buttonText="toggle the Use Cached D3DXMeshes Viewport"
  3.  
  4. --start macro
  5.  
  6. -----------------------------------------------------------------------------------------------
  7. --
  8. -- toggles the "Use Cached D3DXMeshes" checkbox of the Viewport configuration
  9. --
  10. -----------------------------------------------------------------------------------------------
  11.  
  12. --diable it while
  13. dialogMonitorOps.enabled = false
  14. global prefsDialog_hwnd = undefined
  15. global retMessage=""
  16. fn toggleCachedD3DMeshes = (
  17.  
  18. --Constants for sendMessage method
  19. local BM_GETSTATE = 0xF2
  20. local BM_CLICK = 0xF5
  21. local BM_SETCHECK = 0xF1
  22. local BST_CHECKED = 0x1
  23.  
  24. local hwnd = dialogMonitorOps.getWindowHandle()
  25. local dialogTitle = uiAccessor.getWindowText hwnd
  26. if (dialogTitle != undefined) then (
  27. if (dialogTitle == "Preference Settings") then (
  28. prefsDialog_hwnd = hwnd
  29. format "We're in the preferences dialog\n"
  30. local hwnd_children = uiAccessor.getChildWindows hwnd
  31. for i = 1 to hwnd_children.count do (
  32. local hwnd_child_title = uiAccessor.getWindowText hwnd_children[i]
  33. if (findString hwnd_child_title "Configure Driver..." == 1) then (
  34. format "found config button... pressing\n"
  35. local hwnd_config = hwnd_children[i]
  36. uiAccessor.pressButton hwnd_config
  37. )
  38. )
  39. )
  40. else if (dialogTitle == "Configure Direct3D") then (
  41. local hwnd_children = uiAccessor.getChildWindows hwnd
  42. for i = 1 to hwnd_children.count do (
  43. local hwnd_child_title = uiAccessor.getWindowText hwnd_children[i]
  44. if (findString hwnd_child_title "Use Cached D3DXMeshes" == 1) then (
  45. format "found the cached button\n"
  46. local hwnd_cached = hwnd_children[i]
  47. local CheckState = windows.sendMessage hwnd_cached BM_GETSTATE 0 0
  48. local IsChecked = bit.get CheckState BST_CHECKED
  49. format "the checkbox was: %\n" IsChecked
  50. -- Uncheck it
  51. if IsChecked then
  52. (
  53. windows.sendMessage hwnd_cached BM_CLICK 0 0
  54. windows.sendMessage hwnd_cached BM_SETCHECK 0 0
  55. format "Cached D3DXMeshes has been disabled.\n"
  56. format "Pressing OK on the ConfigureD3D page\n"
  57. uiAccessor.sendMessageID hwnd #IDOK
  58. format "Pressing OK on the Preferences page\n"
  59. uiAccessor.sendMessageID prefsDialog_hwnd #IDOK
  60. retMessage="Turning the CachedD3DXMeshes *OFF*"
  61. )
  62. -- Check it
  63. else if not IsChecked then
  64. (
  65. windows.sendMessage hwnd_cached BM_CLICK 0 0
  66. windows.sendMessage hwnd_cached BM_SETCHECK 1 0
  67. format "Cached D3DXMeshes has been enabled.\n"
  68. format "Pressing OK on the ConfigureD3D page\n"
  69. uiAccessor.sendMessageID hwnd #IDOK
  70. format "Pressing OK on the Preferences page\n"
  71. uiAccessor.sendMessageID prefsDialog_hwnd #IDOK
  72. retMessage="Turning the CachedD3DXMeshes *ON*"
  73. )
  74. )
  75. )
  76. )
  77. )
  78. true
  79.  
  80. )
  81.  
  82. fn toggleUseCache =
  83. (
  84. dialogMonitorOps.interactive = false
  85. dialogMonitorOps.unregisterNotification id:#setD3DCache
  86. dialogMonitorOps.registerNotification toggleCachedD3DMeshes id:#setD3DCache
  87. dialogMonitorOps.enabled = true
  88. --run it
  89. max file preferences
  90. --disable it!
  91. dialogMonitorOps.enabled = false
  92. dialogMonitorOps.unregisterNotification id:#setD3DCache
  93. --messagebox retMessage
  94. )
  95.  
  96. toggleUseCache()
  97. format retMessage

Report this snippet  

You need to login to post a comment.