Does anyone know if it is possible to make a variable


variable = "string data"

and then have that data stored 'somewhere' such that it is saved with your file? So you change the value, save and close blender, reopen blender, and the code loads up that data from before?

I would like to avoid having to export data to a custom file, but instead have it load automatically with everything else.

I am trying to make a plugin that adds a bone constraint. In reality, it is not a bone constraint, it just connects a shape key to a particular bone in a particular direction to give the effect of easy to use pose space deformation like those found in industry level programs like Maya. And in reality, my variable is going to be a float type column vector

vector_to_save = bpy.context.selected_pose_bones[0].matrix.col[1]
  • 2
    $\begingroup$ You will need a custom property which can be created via the UI (Properties Panel) or with code. $\endgroup$
    – Leander
    Feb 22, 2019 at 7:40
  • $\begingroup$ Are you trying you trying to implement pose space deformations. Like what's found in other software. That would be really cool. $\endgroup$
    – Jack
    Mar 24, 2019 at 11:04

1 Answer 1


Thanks to Leander's comment about custom properties to help me get on the right track.

There is the custom properties subsection in the object tab (found in the properties window). Most of us may be familiar with it, as it is fundamental to doing things such as controlling multiple shape keys or other effects. At the time I knew about these, but not as much as I thought. I didn't want to use these at first because I didn't want the rig's custom properties section to get filled up with a bunch of junk, since I feel that areas should be reserved for users. But since Leander suggested such a thing could be done with code, I looked into the topic further, now searching "properties" as my keyword, to see if I could manage to do this in a discrete way.

https://docs.blender.org/api/2.79/bpy.props.html - "Custom properties can be added to any subclass of an ID, Bone and PoseBone."

At the mention of custom properties being used for bones as well, I looked and found that indeed, there is a hidden custom properties subsection for each individual bone. This is great because: 1 I can't think of any user who would need to go into this section, to manage custom properties per bone, so this stuff should, for the most part, stay out of users' way; 2 it helps perfectly organize where my data should be found, making the coding a bit easier.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .