PDA

View Full Version : Persistent Structs.


DaveWortley
06-30-2011, 10:34 AM
I've created a custom render pass system for use with Deadline. I have a major problem, I've basically created an interface that builds Render Tasks 'Structs' and puts them into an array.... works locally fine.... and the persistent globals stay with the file when re-opening in workstation mode, but I get a problem on Deadline.

Bit of example psuedo code...

persistent global AR_Tasks
AR_Tasks = #()
Struct Task (ID, Frames, Output)

Persistent Global newtask = Task ID:1 Frames:2 Output:"c:\\test\\test01.tga"
append AR_Tasks newtask


Then in as a Deadline MAXScript Scene Processing Job my script is failing here in the code....
...
for task in AR_tasks where Task.id == currentframe do
....

throws the following error....

=======================================================
Exception during render: An error occurred in RenderTasks(): RenderTask: Unexpected exception (Exception caught in 3ds max: -- Unknown property: "id" in undefined
2011/06/29 18:08:21 INF: Loaded C:/Documents and Settings/remote/Local Settings/Application Data/Prime Focus/Deadline/slave/jobsData/MASTER_03_dw.max
2011/06/29 18:10:51 INF: Job: C:/Documents and Settings/remote/Local Settings/Application Data/Prime Focus/Deadline/slave/jobsData/MASTER_03_dw.max
)
at Deadline.Plugins.ScriptPlugin.RenderTasks(Int32 startFrame, Int32 endFrame, String& outMessage)

So the AR_Tasks array global is being persistent but the contents of the array are not... But if i re-open the file locally both are persistent... So I'm a bit stuck till the Thinkbox guys get back to me, but thought I'd open it up to the floor in the hope that someone had come across something like this before.



D

DaveWortley
07-01-2011, 03:24 PM
Ok Ignore the Deadline part of this... it's just the contents of the array not staying persistent....

persistent global AR_Tasks
AR_Tasks = #()
struct Task (ID, Frames, Output)

persistent global newtask = Task ID:1 Frames:2 Output:"c:\\test\\test01.tga"
append AR_Tasks newtask

What's wrong with my code?

DaveWortley
07-01-2011, 03:41 PM
So an array of arrays works fine, but would prefer to be using Structs for easier coding, is there any way to make these persistent between sessions/machines?

denisT
07-01-2011, 04:19 PM
So an array of arrays works fine, but would prefer to be using Structs for easier coding, is there any way to make these persistent between sessions/machines?

the only way that i see is to store all data in an arrays, and on load event create the structure and fill the structure with data from arrays.
here is a sample:

delete objects
for k=1 to 10 do box name:(uniquename "xnode")

persistent global xnodes = #()

callbacks.addScript #filePostOpenProcess \
(
"format \">:%\\n\" maxfilename\n" +
"global LoadData\n" +
"struct LoadData (name, id = -1, nodes = #(), fn init = (name = \"xnodes\"; nodes = #()), fn add node = append nodes node)\n" +
"global testData = LoadData()\n" +
"testData.init()\n" +
"for n in xnodes do testData.add n\n"
) \
id:#xnode_data persistent:on
callbacks.addScript #filePreSaveProcess \
(
"persistent global xnodes = $xnode* as array"
) \
id:#xnode_data persistent:on



run the code in an empty scene... save the scene... reload max to be sure that you have an empty scene... load the saved file...

check xnode and testData global values, and LoadData structure. they have to be created and filled up with data.

plastic
07-01-2011, 05:06 PM
Ok Ignore the Deadline part of this... it's just the contents of the array not staying persistent....

persistent global AR_Tasks
AR_Tasks = #()
struct Task (ID, Frames, Output)

persistent global newtask = Task ID:1 Frames:2 Output:"c:\\test\\test01.tga"
append AR_Tasks newtask

What's wrong with my code?

try this:
put this line into a .ms into /Scripts/Startup/

struct Task (ID, Frames, Output)

Now try again, the array should now stay persistent the same way as other variables.
But the struct has to be defined before the max file is loaded.

CGTalk Moderation
07-01-2011, 05:06 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.