Help with fence addon

Hi everyone, I was taking a swing at my first add-on and I wanted to make a fence as procedurally as possible, I thought about what could be the easiest way and I ended up just creating particle systems, so the user could change the duplicated object and other properties afterwards, the script creates 2 particle systems, one for the big corner posts and one for the smaller ones. The idea was that after it’s created the user could edit the shape of the fence outline and after exiting edit mode it should all rebuild automatically, however right now the best I could come up with is this:


First the user clicks on the addon on the create menu which makes a default fence, then the user can edit the mesh to change the outline of the fence, add more points etc, and finally they have to click on a Update Fence button so that the small posts fit the outline again .
This also has the problem that it resets any changes made by adjusting the properties when executing the operator, it brings the separation and post size back to the defaults. Also right now the way its updating the original mesh is by just using the name, so it only works with 1 fence and if its renamed then it will stop working.

hopefully someone can point me to a better approach of how to achieve this in a more automatic way without having to manually adjust stuff, also any other advice or critiques with regards to the code or how I’m using all the bpy functions etc will be greatly appreciated since I’m still new to this and have yet to wrap my head around a lot of things.

here’s the code to the addon:

http://pastebin.com/xK7eLv5w

I can definitely relate to your frustration. I’ve been trying to do the same thing for a while now, with many different approaches, all with their own hitches and glitches.

But anyway as for the naming thing, you could assign your own property(string I guess) to the object and reference that instead of the name, that way it won’t change when the name does.