Trouble using from_pydata()


I’m coding an add-on under blender 2.78a, and I’m having trouble producing valid input for from_pydata(). You can see my code here:

I’ve whittled it down as far as I can, so it will still reproduce the problem.

To reproduce the problem, load the add-on, then go to the new ‘Clothes’ tab in the Tools panel of the 3D view. Click the “Create Shirt” checkbox. A mesh should be produced.

It’s been created to have cloth physics and sewing springs enabled. If you press ALT-A, the mesh should sew together. The problem is it doesn’t.

If, however, you hit TAB a couple of times to go in and out of Edit mode, and then press ALT-A, the mesh sews together just fine. Somehow tabbing in and out of edit mode fixes it, but I have no idea why.

The validate() call in the code produces a lot of console output that looks like “Poly 20 has invalid edge reference (0), fixed using edge 61”. I’m guessing this means the edge data is wrong. But I don’t know what’s wrong with it.

I’ve searched online, and stared at the code, and tried whatever I could think of. I’m not sure what to do to produce acceptable input for from_pydata. I could sure use some help figuring it out.

Be well,

If in and out of edit mode is the solution, then why not automate it afterwards.

Thanks for the suggestion! I tried it and it worked. But I’m a little worried about the speed hit. In my full add-on, there are are a lot more vertices, and I also have sliders that adjust the shape of the mesh. Using your solution I’m auto-tabbing in and out of edit mode with every adjustment.

Is automated tabbing just something everyone does as a standard practice? It seems like it would be more efficient to avoid it if possible.

Be well,

I think you’re looking for a scene update. Can you try to change frames and see if that works too.