Got them to add the maxscript language at the code snippet site snipplr.com
a maxscript snippet: http://snipplr.com/view/10508/check-the-status-of-a-remote-servers-service/
Here’s the current list of posts tagged as maxscript, skimpy so far i know!
the site gives us easy commenting, community editing, and an easier taggable search interface than the current state of things: cgtalk forums. I think to get wide adoption we might have to make a max or python based interface to make for easier posting/retrieval without having to use the web browser however!
We’ll see how much time i get to escape from the 4 infants to get that done ! (hah)
This handles the services perfectly for me here, I’m doing a little more work on it to support using the server.exe and vrayspawner exe versions as well, but that wont be finished for a while as its a spare time project. I’m really looking for feedback in terms of platforms you’re looking to use it on, and what features would be nice to see in addition.
Install is pretty straightforward, simply unzip into your Scripts directory.. after a bit more testing for various people I’ll throw together an installer, but for now its slightly manual.
after you unzip it, assuming your max is installed in say, C:\3dsmax08\ you should see several files
Maxscript files: Access them as Maxscript Pulldown, Run Script.
C:\3dsMax08\server_tool_lite_05.mcr — Run this to install the script into the Customize UI, under category dbScripts.
C:\3dsMax08\ServerUtilities\server_tool_lite_05.ms — Run this to try out the tool without installing it into the Customize ui..
C:\3dsMax08\ServerUtilities\… There will be a few other exe’s in this directory, mostly commandline utilities that the script calls to batch modify things.
After you run the script the first time, it will create a file C:\3dsMax08\ServerUtilities\ServerToolLite.ini which will save your settings. In the script, it might be easier for you to add 1 server, and then browse to the ServerToolLite.ini file and manually add the other 19 servers in notepad.
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
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
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.
Who would have thought this would be a pain? All i wanted to do was have a default camera zoom to fit on all objects in a scene, regardless of their size/distrobution.
turns out theres code in the maxscript docs that can do it, but it does it by way of modifying the FOV of the camera to fit. thats all good, as long as you’re not working with hugely varying size objects.. re: how far away from the objects is your camera to start will determine how wide the view is. functional, but not ideal.
here’s a little function snippet that does the same functions, but will create a camera, rig it up to a certain direction, and then move it out on its local Z axis until the set of objects is fully in view.
Again, something i’m using in conjunction with Paul’s Batching script refrenced below.
So, today I took up the fun job of building some sort of asset management tool. so obviously the first thing is to figure out what kind of assets you have so that you can sort them! now we’ve collected many many models over the years, from useful, to complete shite. so the not so fun part becomes to sort through all of these we need to see what they are obviously!
combined with a little Thumbnail rendering script i cooked up that will render an Isometric view of the maxfile’s contents, ignore all scene lights, and render with a basic skylight, include a polycount on the render. there are also options in the script whether to use a default skylight lighting scheme, or whether to render the scene using an Ambient Occlusion override material
So. the computer behind me is happily cataloging our whole mess.
I wonder if it’ll be done by morning? 🙂
A couple useful functions for dealing with importing and exporting multiple objects.. has options to export from world 0, whether to export each hierarchy as a separate file, or each individual object as a separate file
this came up in a few different forums today, so figured I’d throw it up.
here’s a little snippet to check the status of a service on a remote server. used as part of a little farm management utility that I’m updating to run with the 64bit stuff and experimenting with the net framework.
fn checkService ServiceName server = ( dotnet.loadassembly "System.ServiceProcess" sc = dotNetObject "System.ServiceProcess.ServiceController" if (server == "") do server = "." -- if no server is supplied, run the check on the local machine sc.Machinename = server try(scServices = sc.GetServices(server))catch(return "Timed Out") for scTemp in scServices do ( if (scTemp.ServiceName as string == ServiceName) then ( --print ( ServiceName + " - " + server + " - " +scTemp.Status.toString() ) return scTemp.Status.ToString() ) ) return "Service Not found" )
Thanks Chris Evans for the maxscript syntax highlighting!