Create Grid should use same function as Geometry Nodes
Running the included script from GitHub you can see that the current ways to create a grid from the python API are, in my experience, at least 1 order of magnitude slower than Geometry Nodes even in 2.93. I suggest
bpy.ops.mesh.primitive_grid_add()
and
bmesh.ops.create_grid()
both be updated to use (as best as possible) the same or similar function used by Geometry Nodes. I'm sure other primitives could also benefit but grid is the only one I've tested.
GitHub Grid Creation Test: github.com/zachEastin/BlenderStuff/blob/main/plane_creation_speed_tests.py
- Meant to be copied and pasted into Blender's text editor and ran from there. Will print out results to the System Console
2 Comments
You know that geometry node functions can only work in geometry zoos, and that's why they're faster, right? Python requires a lot of overhead and setup and bmesh suggests a convenient data structure for edit
Well, that's not quite right, is it. Geo node functions are just that, functions. They can be copied and pasted and called from multiple things. You put the create_grid function in a more accessible file and make calls to it from geometry nodes as well as others functions. While python does have quite a lot of overhead most functions are calls to C functions eventually. A create_grid function that takes 2 integers for the amount of vertices in the x and y axis has virtually no overhead. Besides in the test I provided, I'm creating a node tree, creating nodes, connecting those nodes, changing their settings, applying the geometry node modifier, assigning and deleting meshes all in python and even with all of that "overhead" it's roughly 10x faster than any of the other methods given to us.