Created
April 23, 2017 06:57
-
-
Save atartanian/3e781e14721a7d9a136d253cb0c6dfcd to your computer and use it in GitHub Desktop.
blender script to connect all the points of a mesh object into a line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy, bmesh | |
def main(context): | |
bpy.ops.object.mode_set(mode='EDIT') | |
active_obj = bpy.context.active_object | |
me = active_obj.data | |
bm = bmesh.from_edit_mesh(me) | |
verts = bm.verts | |
edges = [] | |
lenMinusOne = len(verts) - 2 | |
bm.verts.ensure_lookup_table() | |
for vi in range(0,lenMinusOne): | |
new_edge = (verts[vi],verts[vi+1]) | |
bm.edges.new(new_edge) | |
bmesh.update_edit_mesh(active_obj.data) | |
bpy.ops.object.mode_set(mode='OBJECT') | |
class CurvifyPoints(bpy.types.Operator): | |
"""Tooltip""" | |
bl_idname = "object.curvify_points" | |
bl_label = "Curvify Points" | |
@classmethod | |
def poll(cls, context): | |
return context.active_object is not None | |
def execute(self, context): | |
main(context) | |
return {'FINISHED'} | |
def register(): | |
bpy.utils.register_class(CurvifyPoints) | |
def unregister(): | |
bpy.utils.unregister_class(CurvifyPoints) | |
if __name__ == "__main__": | |
register() | |
# test call | |
bpy.ops.object.curvify_points() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @artatanian, thanks alot for this, I found this in a forum trying to make curved entanglements, I still have some kind of error from your code, even using the same blender version you use on the tutorial, console code, do you happen to have a tutorial or something similar for Blender 2.8 onwards?
Thanks again for the great job!