4
$\begingroup$

I am writing an addon to help me manage my multi-file addons.

THIS IS HARD TO EXPLAIN

Its coming along really nicely, but I want it to work no matter what .blend file I have open, so I have it save each project's data to an xml file.

Not knowing that it wouldn't work, I had the panel call two functions, one to update the files for the project, and one to update the xml file. So whenever the UI updated the two functions were called. But I changed something in the 2nd function that actually changed a value in blender and it wouldn't let me because you can't edit blender data from a UI context.

So here is my question: What is the best way to continually update my list based on this external XML file. I really don't want a UI button to update from xml if possible.

Also, if there is a way for the two functions to be run whenever Blender opens that would work as well.

$\endgroup$
9
  • $\begingroup$ Just out of interest: Why XML? $\endgroup$
    – p2or
    Commented Aug 9, 2015 at 9:17
  • 1
    $\begingroup$ @poor because each project has a name, location, a boolean for whether it is an addon or a script, and a list of files in the project. I hadn't ever used XML before and I thought it would be an easy way to store/parse data. And it was. :D $\endgroup$
    – doomslug
    Commented Aug 9, 2015 at 15:17
  • $\begingroup$ JSON is much simpler however. Anyway, how often are the updates supposed to happen? $\endgroup$
    – CodeManX
    Commented Aug 9, 2015 at 19:06
  • $\begingroup$ @CoDEmanX I hadn't thought of JSON.. I will look into that once I fix this problem! But minimum it should update when the addon is enabled (the register function, I can already do this) and whenever blender is opened with the addon already enabled. It would be nice for it to be continually checking for new projects in the xml file, but it doesn't need it. $\endgroup$
    – doomslug
    Commented Aug 11, 2015 at 16:15
  • 1
    $\begingroup$ Have a look here: blender.stackexchange.com/a/7974/1363 (populate_coll() and register()) $\endgroup$
    – CodeManX
    Commented Aug 17, 2015 at 19:18

1 Answer 1

1
$\begingroup$

I ended up using a JSON file. I used handlers to import from the file when it opened just like in this answer: https://blender.stackexchange.com/a/7974/1363

$\endgroup$

You must log in to answer this question.

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