Saving generic data to a blend file

I’m attempting to create a script which will allow users to align and transform objects based on specified points, lines, or planes within objects (or coordinate data from the 3d cursor). I need to store coordinates for 2x[point, line, plane].

Ideally, I would like to store this data per-file, without associating it with any particular mesh object (since I would like to be able to keep the coordinate data that has been grabbed from any mesh object after it has been deleted). If anyone can tell me the best way to go about storing this data, I would appreciate it (or any other suggestions if you happen to think of something).

Edit:
The user would see this functionality as a UI menu or panel of some kind with two sets of point, line and plane data, with some buttons and menus for specifying which operation they would like to perform, and which stored coord data to use (imagine “make collinear” edge1->edge2). The two sets of point, line and plane data would be saved and remembered with the blend file. As far as I can tell from reading the API though so far, you can only associate data with objects in the bpy.data collections, and I simply need to store some primitive matrices and vectors from http://www.blender.org/documentation/blender_python_api_2_63_14/mathutils.html#mathutils.Vector by themselves.

sorry, I do not understand your wish(es) …

You are building a gui to do what exactly?
E.G. you have chosen in the 3DView two edges of ONE object and want to let them make ‘collinear’? hmm ok.
And then WHAT? Wat type of file just data as text or in a *.blend file with what information, remembering what?

Give us your source of the addon and try again to explain what where should be saved … :wink:

Properties

I’m building a gui to allow users to take two separate objects (like two suzannes, for instance) and align them based on their constituent parts. So, you could make any two arbitrary edges collinear on totally separate meshes. Or, any two faces coplanar. Or, you could scale a mesh so that one edge within that mesh is of equal length to an edge in another mesh. Or, slide a portion of a mesh or an object in a direction specified by an edge (vector). You can imagine performing these operations on two separate parts of a single mesh as well.

The key feature of the addon is being able to transform and align separate objects or separate pieces of a mesh based on specified constituent geometry. The way the user specifies which constituent parts the transformations are based on is special as well: the addon doesn’t actually store the specified vertex or edge that the user picks. Instead, it stores the coordinates of that vertex (or the two coords for an edge) only. This way, the user is free to create imagined geometry around which to base a transformation. Or, the user can specify an edge from one mesh, and use that as an axis to rotate an entirely different mesh around. So, the constituent geometry that the user specifies is

  1. Not associated with any particular mesh. This is intentional. It gives you the option of transforming a mesh based on its own constituent parts, or of transforming a mesh based on the constituent parts of another mesh.

  2. Based on either real or imagined geometry. I’m not storing and remembering an actual vertex from an actual mesh. I’m storing only the coordinates of that vertex. So, the user can specify an edge to be used as an axis in transformations by opening the UI menu, and under “Line:” the user can record point 1 of that line as being the coords of a vertex on a mesh, and point 2 of that line can be a 3D cursor location (or any number of other values).

So, to be clear, I want to store point{x,y,z} + line{ {x,y,z}, {x,y,z} } + plane { {x,y,z}, {x,y,z}, {x,y,z} }, times two. I’m thinking at this point that I will try to store this information as part of a text datablock (because I don’t see a way to store data that isn’t a member of bpy.data or their submembers otherwise) which I can convert back and forth to usable values during calculations at runtime. That’s my current direction, without any real guidance except for the API (which is why I’m asking for suggestions).

http://www.blender.org/documentation/blender_python_api_2_63_14/bpy.types.Text.html#bpy.types.Text

@ni-ki-o-kin
So, would my approach above be a good way to go then? (Storing this data on a new text datablock that I create for my script)

Storing a text file of data is just Python and is in fact easy. And could be read if the name and place of the stored data
is somehow known (or given) to an addon.

another possibility create suitable meshes (only vertices and edges so they do not disturb at render-time) , wich could be saved in a (spcial) .blend file …

you don’t need to save your data to an external text-file.


bpy.context.scene["mypoint"] = [2, 1.1, 3]
print("this is the x-value from mypoint:")
print(bpy.context.scene["mypoint"][0])

Ahh, great idea! Don’t know why it didn’t occur to me in the first place…

Thanks.