[3dsMax | mxs/c#] Saving plugin parameters

Hello everyone,

I am currently working on a scripted plugin to create (and store) paths, on which the user can place objects.

[ul]
[li]The plugin can store multiple paths (like a 3dsMax Shape having multiple splines)[/li][li]A path consists of segments and points (like a 3dsMax Spline consists of Segments & Knots)[/li](for curved segments)
[li]Each placed object can be referenced by multiple paths[/li](for example a T cross, where an object is placed at the intersection point)
[/ul]

So I guess the proper structure would be:

Pseudo - Code


[B]struct [/B]Main
(
	paths = #() -- all path structs
	uniqueObjects = #() -- all referenced objects (max nodes)
)

[B]struct [/B]Path
(
	uniquePoints = #() -- all path points (point3)
	segments = #() -- all segment structs
)

[B]struct [/B]Segment
(
	referencedPoints = #() -- reference to unique path points
	referencedObjects = #() -- reference to unique objects
)

Question#1: Now my biggest problem is storing all the data. Plugins only save int, point3 etc. arrays, so I assume saving everything to an XML file would be the way to go?
Question#2: How do you save and load “reference types”?
Question#3: Would you advise against using C# for this? I have some experience with mxs <-> C# and I like C#. I would put all classes, loading/saving and some math stuff in C#

Sidenote#1: I am using a scripted object as “root node” (holds all path data + I want it to save a mesh later on)
Sidenote#2: I am using a scripted manipulator to render the paths (while the object is selected), plus some gizmo helpers during the object placement phase

Advice and suggestions are very welcome! I have most of the functionality I need ready (in separate pieces), but I’d like some professional insight before putting it together the wrong way and hating myself for not asking. :slight_smile:

Sorry for any “Shape->Spline->Segment->Knot” to “Path->Segment->Point” confusion ^^

This seems to be the way to serialize/deserialize preserving object references. Which would probably also be the answer question #3.

I could also use bitArrays instead of references, damn too many options!

#1.) I don’t know about saving persistent data with a C# plugin, but I have had to save serialized data for our project.
Our system stores external data as *.json files for our game characters.
I utilized json.net and wrote a struct just for holding max script json functions, and the tools are mostly mxs.
to keep persistent scene data, I just create invisible pointer objects and store json data as a string to the object properties.
a possibly superior approach might beusing Custom Attributes on the scene root node.

#2.) don’t know much about referencing, but maybe this article on weak referencing in mxs will help…maybe not.
#3.) can’t advise, but I managed to get by with 99% mxs in my case.

Thank you for your answer!

I read quite a few times now that mxs “still” (with all options available) is a good choice to get things done quickly. I guess for my purposes speed is not an issue, so mxs will probably do just fine.

I’ll stick with XML though, store the file path in the plugin parameters and load everything when needed.

Thanks for the links, the nodeTransformMonitor seems to be handy!