I’d like to use the knife tool from within Python. I found bpy.ops.mesh.knife_tool(). As far as I can tell, this activates the knife tool. But then how do I define and make the cut, programmatically?
Using the knife seems like it would be much simpler than bmesh.utils.face_split().
I’m sorry, there is no programmatic way to use the knife tool right now. The current tool relies very much on calculations drawn in a 2d viewport, with snapping/visual feedback, in order to define where the cuts are. Can you suggest a programmatic API call that would make sense to you as a programmer?
Sure. I can discuss, conceptually, how it might work. I don’t yet know enough about Blender to flesh out all of the details though.
Although the manual interface could be duplicated by defining the observer’s position and the knife’s segments, I’m not sure that is the best API to offer through Python. If that were available, it is flexible enough that I could make it work for current needs.
The better solution for my current case, however, would be to define a plane which would cut intersecting faces. To make this more powerful and flexible, the API would accept the knife’s geometry along with a definition of which edges are cutting edges. Cutting edges would cut inward along the plane, and cuts would be limited to the planar region.
For instance, if only the “front” edge were a cutting edge, and cut-through was turned off, the the effect would be similar to manually using the knife with cut-though turned off. If all four edges were defined as cutting edges, then the cut would be equivalent to making four manual cuts, moving around the object 90 degrees between each cut. Except that manual cuts would not allow for the “limits” the API would provide.
An even more powerful version would allow the knife’s geometry to be defined as any planar complex polygon. Since cuts from each cutting edge would proceed “inward” along the plane until encountering another edge, a complex polygon would allow complex cuts. (No pun intended.)
Does this make sense to you? I’d have a Knife class, which would hold any options, such as cut-through, as well as the geometry and definition of cutting edges. I don’t have enough understanding of how the Blender API is laid out to specify how the geometry would be defined or how one would communicate which edges are cutting edges.
This is a reasonable idea for a programmable API. Though of course it doesn’t expose all the capabilities of the knife tool.
Does this make sense to you? I’d have a Knife class, which would hold any options, such as cut-through, as well as the geometry and definition of cutting edges. I don’t have enough understanding of how the Blender API is laid out to specify how the geometry would be defined or how one would communicate which edges are cutting edges.
Thoughts?
Makes sense. The operator would have to get some new arguments. One possibility would be some number of vector arguments, representing points that are corners of a cutting plane. Another would be to actually construct the plane (a temporary) and pass that cutting plane in as an argument.