Archive for November, 2008
3dsmax DirectX oddity
by Dave Buchhofer on Nov.25, 2008, under maxscript, utility
Basic Problem: IT has enforced a Screensaver password policy here now Now, with the D3D view port driver, when you come back from a locked workstation, it doesn’t always instantiate the DX display correctly. we’re noticing on our workstations that it will come back working to a point.. IE: All of the geometry on screen is selectable, but only ~20% of it is displayed with edges in max.
a hack to fix it without having to restart max every time the computer locks on you, I’ve found i can Disable and then Enable the Direct3D Cached meshes.. this works.. in a crappy sort of way.
Here’s some code that toggles the d3d cached.. it also helps to show how to access things in max that are not readily open to the maxscript language, by using windows messaging to “push” buttons on dialogs! most credit to Richard at cgtalk!
toolTip="toggle the Use Cached D3DXMeshes Viewport" buttonText="toggle the Use Cached D3DXMeshes Viewport" --start macro ----------------------------------------------------------------------------------------------- -- -- toggles the "Use Cached D3DXMeshes" checkbox of the Viewport configuration -- ----------------------------------------------------------------------------------------------- --diable it while dialogMonitorOps.enabled = false global prefsDialog_hwnd = undefined global retMessage="" fn toggleCachedD3DMeshes = ( --Constants for sendMessage method local BM_GETSTATE = 0xF2 local BM_CLICK = 0xF5 local BM_SETCHECK = 0xF1 local BST_CHECKED = 0x1 local hwnd = dialogMonitorOps.getWindowHandle() local dialogTitle = uiAccessor.getWindowText hwnd if (dialogTitle != undefined) then ( if (dialogTitle == "Preference Settings") then ( prefsDialog_hwnd = hwnd format "We're in the preferences dialog\n" local hwnd_children = uiAccessor.getChildWindows hwnd for i = 1 to hwnd_children.count do ( local hwnd_child_title = uiAccessor.getWindowText hwnd_children[i] if (findString hwnd_child_title "Configure Driver..." == 1) then ( format "found config button... pressing\n" local hwnd_config = hwnd_children[i] uiAccessor.pressButton hwnd_config ) ) ) else if (dialogTitle == "Configure Direct3D") then ( local hwnd_children = uiAccessor.getChildWindows hwnd for i = 1 to hwnd_children.count do ( local hwnd_child_title = uiAccessor.getWindowText hwnd_children[i] if (findString hwnd_child_title "Use Cached D3DXMeshes" == 1) then ( format "found the cached button\n" local hwnd_cached = hwnd_children[i] local CheckState = windows.sendMessage hwnd_cached BM_GETSTATE 0 0 local IsChecked = bit.get CheckState BST_CHECKED format "the checkbox was: %\n" IsChecked -- Uncheck it if IsChecked then ( windows.sendMessage hwnd_cached BM_CLICK 0 0 windows.sendMessage hwnd_cached BM_SETCHECK 0 0 format "Cached D3DXMeshes has been disabled.\n" format "Pressing OK on the ConfigureD3D page\n" uiAccessor.sendMessageID hwnd #IDOK format "Pressing OK on the Preferences page\n" uiAccessor.sendMessageID prefsDialog_hwnd #IDOK retMessage="Turning the CachedD3DXMeshes *OFF*" ) -- Check it else if not IsChecked then ( windows.sendMessage hwnd_cached BM_CLICK 0 0 windows.sendMessage hwnd_cached BM_SETCHECK 1 0 format "Cached D3DXMeshes has been enabled.\n" format "Pressing OK on the ConfigureD3D page\n" uiAccessor.sendMessageID hwnd #IDOK format "Pressing OK on the Preferences page\n" uiAccessor.sendMessageID prefsDialog_hwnd #IDOK retMessage="Turning the CachedD3DXMeshes *ON*" ) ) ) ) ) true ) fn toggleUseCache = ( dialogMonitorOps.interactive = false dialogMonitorOps.unregisterNotification id:#setD3DCache dialogMonitorOps.registerNotification toggleCachedD3DMeshes id:#setD3DCache dialogMonitorOps.enabled = true --run it max file preferences --disable it! dialogMonitorOps.enabled = false dialogMonitorOps.unregisterNotification id:#setD3DCache --messagebox retMessage ) toggleUseCache() format retMessage
Maxscript: Grid by Name
by Dave Buchhofer on Nov.07, 2008, under Architecture, maxscript, utility
Here’s a useful one i made in 2003, one of my first scripts actually! posting it up because i find myself using it ~60 times a day on this current project with curved/angled bits all over it!
A Helper dialog to speed up working with custom Grids. Helps immensely in the workflow of angular modeling (read: silly modern architecture) when combined with a hotkey to create grid and autogrid >:)
Basics: It populates the dialog with all current grids in the scene, including the HomeGrid. you can double click on any grid to activate that, also has buttons to change the view to match the grid, and to select the current active grid. also includes a cycle of the Toolmodes (View/World/Parent/Screen/Local/Gimbal/Grid)
– if there are no grids in the scene, then toggle between the toolmodes
– if there is just 1 grid in the scene, toggle between it and the Home Grid
– if there are grids in the scene, open the window
– if there are grids in the scene and the window is already open, toggle between the grids
Maxscript: Vray Light Calc Filenames
by Dave Buchhofer on Nov.02, 2008, under maxscript, vray
Here’s a relatively simple script thats already saved me many headaches.
Basic Gist: as its set up It will create a directory called ‘Calcs’ under the directory where your maxfile is at, and will switch your filenames for vray irradiance maps and light cache back and forth between saving to, and loading from file in that directory, it will save the calcs as “maxfilename_cameraname.vrlmap/vrmap’
its set to use a UNC directory where possible, and to use irradiance map and light cache. Theres not much error checking in it, its currently set up to work for us internally, If anyone has issues with it, you can contact me. I think its helpful, but not ‘solid?’ enough to drop up onto scriptspot as yet.
Cheers.
Recent work
by Dave Buchhofer on Nov.02, 2008, under Architecture, Portfolio, video
I’ve been a bit busy this month oversee’ing a fair sized animation project, so I’ve been a bit away from the scripting fun of late. There’s a few useful tricks I’ve picked up and will work out some posts shortly
Here’s a couple shot snippets from one of the latest projects. 2 out of 20ish from a pretty large site ![]()













