Hi all,
I’m currently simming locally and then copying my cache to our servers for the render farm - obviously this involves a bit of manual work or scripting.
Would it be possible to add a “backup cache” location where the .aur files could be copied to once simulating has finished, or even a secondary input path so that if the primary cache is not found (because it was saved locally and then backed up to a server) then the secondary path would be used.
I was considering setting this up via maxscript (if possible) but thought that other users may find it useful. Of course if something similar already exists then I would love to know where!
Cheers
Why not just write cache to shared server? it doesn’t have to be ‘local’ . Helps if you always address as UNC
Writing to a network location is slower than a local drive, which in turn makes phoenix take longer before it can start the next frame. Writing huge cache files can also cause a slowdown for other users on the network.
Ah, negative - such functionality does not exist yet - if you can script it yourself, please go ahead!
So I managed to cobble something together but I’ve run into a bit of an issue.
In the OnSimulationEnd I created a variable for the original cache path (on the network drive) and created an array of the files using GetFiles.
Whenever I add the following code:
for i in OriginalFiles do
(
deleteFile I
)
I get the error message
-- Security Exception: MAXScript command embedded in the current scene could be unsafe and its execution has been blocked for the current 3ds Max session: deleteFile "C:\Users\USER\Desktop\tempCache\test_0000.aur"
Is there any way to tell max that the running code is safe? Otherwise when I try to copy the new/local files to the network it fails as the files already exist (albeit as an older version). I can manually clear the network cache before running the sim or manually copy them over later but that kind of defeats the point haha.
Hey Svetlin.
Probably a negative on the above. Mostly it’s just me using the script in the studio so remembering to delete my existing cache on the network isn’t a huge problem to remember.
Another issue that I am running into is that when I try simulating with my “set cache to local drive” script, it fails if I have just opened the scene but if I open the phoenix script window and replace the text (with the exact same code) it works again. Any idea why this might be?
I don’t have the exact error to hand but it was something along the lines of
unexpected exception: this = undefined
Oh, how can I have this error show up here as well? Is your code not running on one of the OnSimulationBegin/End/etc Phoenix callbacks?
Hey, the exact error I’m getting is this:
-- MAXScript ExecuteMAXScriptScript Exception:
-- Type error: Call needs function or class, got: undefined
-- MAXScript callstack:
-- thread data: threadID:12548
-- ------------------------------------------------------
-- [stack level: 0]
-- In top-level
-- MAXScript ExecuteMAXScriptScript Exception:
-- Type error: Call needs function or class, got: undefined
-- MAXScript callstack:
-- thread data: threadID:12548
-- ------------------------------------------------------
-- [stack level: 0]
-- In top-level
I did wonder if it was because I was doing
local sim = this
before the OnSimulationBegin function, but I have also tried defining Local sim = “” at the start of the script and then sim = this from within the OnSimulationBegin function, but this doesn’t seem to help.
I also discovered that it turns out I don’t need to re-copy the code in, but rather run the sim a second time and the code works. Very odd.
Ah, so the “this” object is set to the actual Simulator object right before OnSimulationBegin(), OnSimulationStep() and OnNewFrame() are called.
Also, the entire script in the Phoenix maxscript editor gets executed once when the simulation is started, after “this” is set, but before OnSimulationBegin() is called.
Is the “local sim = this” code in a function that you are calling before OnSimulationBegin()?
Asking because 3ds Max will error out that it needs to be “global sim = this” if it’s simply at the top of the Phoenix maxscript file.
Sorry if I am asking about small things, but I need to understand better what is happening 
Hi Svetlin,
Looking at my original, it looks like I’m calling “local sim = this” before the OnSimulationBegin function. I think in my test yesterday I had modified it to
local sim = ""
before any of the callbacks and then
sim = this
within the OnSimulationBegin callback, but I think I had the same error.
If I get the chance I’ll try to test today and get you a proper answer
Sorry if I am asking about small things
Not at all! I’m an artist first and scripter second so there’s bound to be bugs in my code haha.
Ah, does “global sim = this” throw any errors?